springMVC项目启动时报错
java.lang.IllegalStateException: Error starting child
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [org_apache_tomcat_websocket] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
23-Sep-2020 16:37:43.364 涓ラ噸 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method [createStandardContext]
javax.management.RuntimeOperationsException: Exception invoking method [manageApp]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [org_apache_tomcat_websocket] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
[2020-09-23 04:37:43,388] Artifact springMVC:war exploded: Error during artifact deployment. See server log for details.
解决方法
在web.xml文件末尾加上:<absolute-ordering />
<servlet-mapping>
<servlet-name>spring_mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<absolute-ordering />
</web-app>
导致这个问题出现的根本原因是某个jar包使得项目中出现了超过一个web片段(web fragment),关于web片段这个概念的理解,个人理解如下(仅供参考):
- web片段是一个web项目中的组成部分,这个组成部分可以和其他web片段共同实现web的功能。
- servlet3.0引入了web片段的支持,如果在servlet3.0中使用多个web片段,需要加入绝对排序标签。
关于web片段详细可参考:https://blog.csdn.net/pursueexcellence/article/details/89981690