-
Bug
-
Resolution: Obsolete
-
Major
-
None
-
2.3.4.Final
-
None
-
None
Found this while trying to get s-ramp and s-ramp-ui deployed and working together on JBoss AS 7. In our case, s-ramp is a RESTEasy WAR that provides some rest endpoints. Then s-ramp-ui is a GWT UI for s-ramp, and uses RESTEasy as a client to access those endpoints. I was getting ClassCast exceptions in the client (which I worked around - more later).
Note #1: we are using a newer version of RESTEasy than what JBoss AS 7 packages, and we include it in our WARs.
Note #2: we exclude the JBoss RESTEasy module using the jboss-deployment-structure.xml file included in both WARs.
Ultimately, the problem seems to be that RESTEasy stores an instance of the ProviderFactory in a static variable in RuntimeDelegate. Since JBoss AS 7 provides this class, the instance is stored in a static variable shared by both WAR deployments. However, the instance itself has a class that comes from one of the WARs. So when the other WAR tries to create its own instance, you get a class cast exception.
I have created a stripped down maven project to show this problem. Attached to this ticket are:
1) the full maven project (parent project with two WAR modules)
2) two RESTEasy WARs
To reproduce this problem, simply deploy the two WARs to JBoss AS 7 and then hit the following URLs in order:
http://localhost:8080/rest-easy-test-first/feed
http://localhost:8080/rest-easy-test-second/feed
http://localhost:8080/rest-easy-test-first/feed
The first URL will work and show an Atom feed. The second URL will also work and show an Atom feed. The third URL will fail with:
java.lang.ClassCastException: org.jboss.resteasy.core.ThreadLocalResteasyProviderFactory cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory
org.jboss.resteasy.spi.ResteasyProviderFactory.getInstance(ResteasyProviderFactory.java:351)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:222)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
- is duplicated by
-
AS7-5877 ClassCastException with ResteasyProviderFactory when including RESTEasy in two WARs
- Resolved