I am trying to write simple RESTEasy client. Below given is sample code:
Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target("http://localhost:8080/context/path"); Response response = target.request().post(Entity.entity(object, "application/json")); //Read output in string format String value = response.readEntity(String.class);
I get exception at line:
Client client = ClientBuilder.newBuilder().build();
I see following errors in my console:
16:07:57,678 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) java.lang.NoSuchMethodError: org.jboss.resteasy.spi.ResteasyProviderFactory.(Lorg/jboss/resteasy/spi/ResteasyProviderFactory;)V 16:07:57,679 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration.(ClientConfiguration.java:44) 16:07:57,680 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:317) 16:07:57,680 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:49)
I have added resteasy client dependancy in pom.xml as:
org.jboss.resteasy resteasy-client 3.0.8.Final
My code is deployed on JBOSS EAP 6.1. JDK version is 1.7.
Update: I also tried adding resteasy jax-rs dependancy in my pom. I also verified if ResteasyProviderFactory is enabled by adding following lines in my web.xml:
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
Please find below list of maven dependancies:
org.jboss.spec.javax.ejb jboss-ejb-api_3.1_spec provided javax.enterprise cdi-api provided org.hibernate.javax.persistence hibernate-jpa-2.0-api provided org.hibernate hibernate-validator provided org.jboss.resteasy resteasy-jaxrs 3.0.8.Final provided org.jboss.resteasy resteasy-client 3.0.8.Final com.google.code.gson gson 2.2.4 junit junit test org.jboss.arquillian.junit arquillian-junit-container test org.jboss.arquillian.protocol arquillian-protocol-servlet test
But it doesnt work.
From exception, I am not able to figure out what is missing. I am not able to find any references for this issue on SO or any other forums. Please let me know, if you have seen this issue earlier and you know how to fix it. Thanks.
Update 11 June 2014:
After referring this blog and by excluding some resteasy and jackson modules, I tried creating similar jboss-deployment-structure.xml and keeping it in META-INF folder in my EJB project. This solved my issue of NoSuchMethodError for "org.jboss.resteasy.spi.ResteasyProviderFactory.(Lorg/jboss/resteasy/spi/ResteasyProviderFactory;)" . Structure of my jboss-deployment-structure.xml is:
But now I see similar exception for other method:
Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response.readEntity(Ljava/lang/Class;)Ljava/lang/Object; at com.example.data.DemoProxyBean.callDemoTx(DemoProxyBean.java:59) [demo-service.jar:] at com.example.data.DemoProxyBean$Proxy$_$$_WeldClientProxy.callDemoTx(DemoProxyBean$Proxy$_$$_WeldClientProxy.java) [demo-service.jar:]
And I see this exception at line:
String value = response.readEntity(String.class);
Weird thing is that, when I inspect "response.readEntity(String.class)", while debugging, I can see the String value. But when I try to go to step to next line, I see this error. Can you please guide me, what could be the issue?
Further update:
I referred to this JBOSS Issue tracker. But it was related to WildFly, and not EAP server. It asks us to exclude module "javaee-api". I tried excluding "javaee-api" module, but it also does not work.