当我尝试配置我的第一个应用程序时,我收到此错误。战争成功生成但是当我点击我的项目的URL时,网页上出现此错误并且控制台中出现相同的错误:
堆栈跟踪
2013-07-20 17:05:49,100 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/testing]] (http-127.0.0.1-8080-1) Exception sending request initialized lifecycle event to listener instance of class org.springframework.web.context.request.RequestContextListener
java.lang.IllegalArgumentException: Request is not an HttpServletRequest: org.apache.catalina.connector.RequestFacade@2b617c79
at org.springframework.web.context.request.RequestContextListener.requestInitialized(RequestContextListener.java:54)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:180)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:724)
2013-07-20 17:06:12,617 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/testing]] (http-127.0.0.1-8080-1) Exception sending request initialized lifecycle event to listener instance of class org.springframework.web.context.request.RequestContextListener
java.lang.IllegalArgumentException: Request is not an HttpServletRequest: org.apache.catalina.connector.RequestFacade@f4ffab5
at org.springframework.web.context.request.RequestContextListener.requestInitialized(RequestContextListener.java:54)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:180)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:724)
答案 0 :(得分:1)
检查您的战争中是否碰巧没有 servlet-api 库。如果是这样,您将不得不删除它,因为服务器提供了此库。
<强>解释强>
HttpServletRequest
由 servlet-api 库提供,该库通常由服务器(JBoss,Tomcat等)加载。
如果您的应用程序中也存在库,则它会被不同的classloaders多次加载:应用程序类加载器和服务器默认类加载器。
问题是,服务器加载的HttpServletRequest
无法转换为应用程序加载的HttpServletRequest
,反之亦然。