ResteasyProviderFactory exception in Glassfish
I'm having some trouble invoking a RESTful webservice using the Client Framework provided by RESTEasy. Whe开发者_C百科n I try to register the ResteasyProviderFactory I got a ClassCastException and nothing more works.
Here's the code:
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
LifeGoalClient leClient = ProxyFactory.create(LifeGoalClient.class, "http://localhost:8080/TutorFinanceiro");
List<LifeGoal> lifeGoals = leClient.getLifeGoals();
JOptionPane.showMessageDialog(null, lifeGoals);
return lifeGoals;
And the exception:
java.lang.ClassCastException: com.sun.jersey.server.impl.provider.RuntimeDelegateImpl cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory
I'm using Glassfish 3.0.1 and Resteasy 2.2.1.
I searched through the web but found no solution or no relevant info in respect to this. If anyone have a solution or an alternative way of doing this, please help me!
Thanks in advance
I did force resteasy over jersey in glassfish by adding a file named javax.ws.rs.ext.RuntimeDelegate in the class path at "META-INF/services", wich contain only the following line : org.jboss.resteasy.spi.ResteasyProviderFactory
However, for me, all seemed to work fine until I try to use resteasy-cdi. Adding that last artifact to my dependencies and configuring the required context-param did dig up the same classcast problem.
This is caused by conflicting jax-rs implementation - jersey and resteasy. In order to prevent the error above, you can add
<context-param>
<param-name>resteasy.use.deployment.sensitive.factory</param-name>
<param-value>false</param-value>
</context-param>
in your web.xml.
By doing so, resteasy will choose instance of ResteasyProviderFactory.
精彩评论