org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher无法转换为javax.servlet.Servlet [英] org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher cannot be cast to javax.servlet.Servlet
问题描述
我正在使用Rest Web Service并使用Maven构建项目.该项目正在成功构建,但是当我点击url以测试其余的Web服务时,我正在跟踪异常.
I am using rest web service and building the project with maven. The project is building successfully, but when i hit url to test rest web services I am getting following exception.
java.lang.ClassCastException: org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
通过谷歌搜索(Google可能已成为动词:D),我发现该问题与jboss as7有关,因此我尝试将pom.xml更改为较低版本,以便于使用.但是问题仍然存在.这是我的web.xml现在的样子....
By googling(Google probably has become a verb :D) i found that the issue is related to jboss as7, so i tried to changed my pom.xml to lower version for resteasy. However the problem still persists. Here is what my web.xml now looks like....
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
<version>3.0.6.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jettison-provider</artifactId>
<version>3.0.4.Final</version>
</dependency>
我该如何解决此错误?
推荐答案
所有这些依赖项均由服务器提供,应标记为<scope>provided</scope>
.在WildFly,JBoss AS 7.x或JBoss EAP 6.x上运行时,您也不需要org.jboss.resteasy:resteasy-servlet-initializer
.
All of those dependencies are provided by the server and should be marked as <scope>provided</scope>
. You also don't need the org.jboss.resteasy:resteasy-servlet-initializer
when running on WildFly, JBoss AS 7.x or JBoss EAP 6.x.
在文档指出resteasy-servlet-initializer
仅在不是 WildFly或JBoss AS/EAP容器的容器中需要.
In the documentation it states the resteasy-servlet-initializer
is only needed in containers that are not WildFly or JBoss AS/EAP containers.
这篇关于org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher无法转换为javax.servlet.Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!