在JBOSS整合web项目中,启动时报错。
org.jboss.deployment.DeploymentException: Document root element "web-app",
主要还是web.xml的问题,如果在web.xml中没有下面代码
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
会报出:
org.jboss.deployment.DeploymentException: Document root element "web-app", must match DOCTYPE root "null".; - nested throwable: (org.xml.sax.SAXParseException: Document root element "web-app", must match DOCTYPE root "null".)
是因为xml文件没有定义约束的dtd文件导致的,需要添加上。
新添加了上述DTD约束,继续报错如下
org.jboss.deployment.DeploymentException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".; - nested throwable: (org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".)
解决办法在web-app标签中,完全按照上面的顺序配置即可。