MAVEN启动tomcat报错
1、StrutsPrepareAndExecuteFilter cannot be cast to javax.servlet.Filter
原因分析:
1)servlet-api包重复,JRE中含有该包,需要除去,使用tomcat下的servlet-api即可;
2)web.xml中struts2配置错误,应该配置如下
<!-- 过滤器支持的struts2类 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- /*代表过滤器拦截所有的请求,也就是说不管你访问的后缀名是什么如jsp,action,do他都拦截
而*.action代表过滤器只拦截以action结尾的请求,其他的如jsp,do结尾的都不管 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2、
java.lang.ClassCastException: org.apache.cxf.transport.servlet.CXFServlet cannot be cast to javax.servlet.Servlet
原因分析:
<properties>由于servlet-api jar的冲突,需要去掉geronimo-servlet_x.x_spec-x.x.jar即可解决问题,贴出配置
<cxf.version>2.2.3</cxf.version></properties><dependencies><dependency><groupId>org.apache.cxf</groupId><artifactId>apache-cxf</artifactId><version>${cxf.version}</version><exclusions><exclusion><groupId>org.apache.geronimo.specs</groupId><artifactId>geronimo-servlet_2.5_spec</artifactId></exclusion></exclusions><type>pom</type></dependency></dependencies>