1

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)

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>

How can i fix this bug?

Sanchit Jain
  • 119
  • 3
  • 15

1 Answers1

0

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.

In the documentation it states the resteasy-servlet-initializer is only needed in containers that are not WildFly or JBoss AS/EAP containers.

James R. Perkins
  • 16,800
  • 44
  • 60
  • Thank-you that was helpful . But i am getting another exception now, similar to this [question](http://stackoverflow.com/questions/25224581/javax-ws-rs-notfoundexception-could-not-find-resource-for-full-path) – Sanchit Jain Aug 27 '14 at 19:40
  • It is displaying warning message : resteasy.scan is no longer supported. Use a servlet 3.0 container and the ResteasyServletInitializer – Sanchit Jain Aug 27 '14 at 19:42
  • Have a look at http://docs.jboss.org/resteasy/docs/3.0.4.Final/userguide/html/Installation_Configuration.html#d4e40. The ResteasyServletInitializer shouldn't be needed with JBoss AS or EAP. – James R. Perkins Aug 27 '14 at 22:55