web.xml: invalid content was found starting with element 'init-param' 

Joined:
08/13/2009
Posts:
172

July 17, 2010 03:16:53    Last update: July 17, 2010 03:18:25
This error happens when the ordering of elements in web.xml is not correct. For example, in a <servlet> declaration, <servlet-name> should come before <servlet-class>. If you switch the order of <servlet-name> and <servlet-class>, you'll get this error.

This was my stack trace in JBoss when I declared <load-on-startup> before <init-param> for a servlet:
DEPLOYMENTS IN ERROR:
  Deployment "vfszip:/C:/local/jboss-5.1.0.GA/server/default/deploy/jstl-demo.wa
r/" is in error due to the following reason(s): org.xml.sax.SAXException: cvc-co
mplex-type.2.4.a: Invalid content was found starting with element 'init-param'.
One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns
/javaee":security-role-ref}' is expected. @ vfszip:/C:/local/jboss-5.1.0.GA/serv
er/default/deploy/jstl-demo.war/WEB-INF/web.xml[12,21]

        at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(Dep
loyersImpl.java:993)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(Dep
loyersImpl.java:939)
        at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainD
eployerImpl.java:873)
        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter
.checkComplete(MainDeployerAdapter.java:128)
        at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDSca
nner.java:369)
        at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScan
ner.java:255)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44
1)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java
Share |
| Comment  | Tags