Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ResteasyProviderFactory exception in Glassfish

I'm having some trouble invoking a RESTful webservice using the Client Framework provided by RESTEasy. When 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

like image 260
Paulo Victor Avatar asked Jun 02 '11 13:06

Paulo Victor


1 Answers

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.

like image 139
baraber Avatar answered Sep 25 '22 18:09

baraber