title: RESTEasy Client + NoSuchMethodError
body: <p>I am trying to write simple RESTEasy client. Below given is sample code:</p>
  
  <pre><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);
  </code></pre>
  
  <p>I get exception at line:</p>
  
  <pre><code>Client client = ClientBuilder.newBuilder().build();
  </code></pre>
  
  <p>I see following errors in my console:</p>
  
  <pre><code>16:07:57,678 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) java.lang.NoSuchMethodError: org.jboss.resteasy.spi.ResteasyProviderFactory.&lt;init&gt;(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.&lt;init&gt;(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)
  </code></pre>
  
  <p>I have added resteasy client dependancy in pom.xml as:</p>
  
  <pre><code>  &lt;dependency&gt;
        &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
        &lt;artifactId&gt;resteasy-client&lt;/artifactId&gt;
        &lt;version&gt;3.0.8.Final&lt;/version&gt;
    &lt;/dependency&gt;
  </code></pre>
  
  <p>My code is deployed on JBOSS EAP 6.1. JDK version is 1.7.</p>
  
  <p>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:</p>
  
  <pre><code>  &lt;listener&gt;
      &lt;listener-class&gt;org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap&lt;/listener-class&gt;
    &lt;/listener&gt;
  </code></pre>
  
  <p>Please find below list of maven dependancies:</p>
  
  <pre><code>&lt;dependencies&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.spec.javax.ejb&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-ejb-api_3.1_spec&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.enterprise&lt;/groupId&gt;
          &lt;artifactId&gt;cdi-api&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-jpa-2.0-api&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
          &lt;artifactId&gt;resteasy-jaxrs&lt;/artifactId&gt;
          &lt;version&gt;3.0.8.Final&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
        &lt;artifactId&gt;resteasy-client&lt;/artifactId&gt;
        &lt;version&gt;3.0.8.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.2.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.arquillian.junit&lt;/groupId&gt;
          &lt;artifactId&gt;arquillian-junit-container&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.arquillian.protocol&lt;/groupId&gt;
          &lt;artifactId&gt;arquillian-protocol-servlet&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;               
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>But it doesnt work.</p>
  
  <p>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.</p>
  
  <hr>
  
  <p><strong>Update 11 June 2014:</strong></p>
  
  <p>After referring <a href="http://theholyjava.wordpress.com/2014/02/04/jboss-modules-suck-its-impossible-to-use-custom-resteasyjax-rs-under-jboss-7/" rel="noreferrer">this blog</a> 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:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jboss-deployment-structure&gt;
     &lt;deployment&gt;
         &lt;exclude-subsystems&gt;
             &lt;subsystem name="resteasy"/&gt;
         &lt;/exclude-subsystems&gt;
       &lt;exclusions&gt;
         &lt;!-- &lt;module name="org.apache.log4j" /&gt; --&gt;
         &lt;module name="org.apache.commons.logging"/&gt;
         &lt;module name="org.jboss.as.jaxrs"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-jaxrs"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-cdi"/&gt;
         &lt;!-- &lt;module name="org.jboss.resteasy.jackson-provider"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-atom-provider"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-jaxb-provider"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-jettison-provider"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-jsapi"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-multipart-provider"/&gt;
         &lt;module name="org.jboss.resteasy.resteasy-yaml-provider"/&gt;
         &lt;module name="org.codehaus.jackson.jackson-core-asl"/&gt;
         &lt;module name="org.codehaus.jackson.jackson-jaxrs"/&gt;
         &lt;module name="org.codehaus.jackson.jackson-mapper-asl"/&gt;
         &lt;module name="org.codehaus.jackson.jackson-xc"/&gt;
         &lt;module name="org.codehaus.jettison"/&gt;
         &lt;module name="javax.ws.rs.api"/&gt; --&gt;
       &lt;/exclusions&gt;
     &lt;/deployment&gt;
   &lt;/jboss-deployment-structure&gt;
  </code></pre>
  
  <p>But now I see similar exception for other method:</p>
  
  <pre><code>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:]
  </code></pre>
  
  <p>And I see this exception at line:</p>
  
  <pre><code>String value = response.readEntity(String.class);
  </code></pre>
  
  <p>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?</p>
  
  <p><strong>Further update:</strong></p>
  
  <p>I referred to this <a href="https://issues.jboss.org/browse/WFLY-1304" rel="noreferrer">JBOSS Issue tracker</a>. 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.</p>