0 Replies Latest reply on May 11, 2015 9:04 PM by Jeferson Dal Molin

    RestEasy Client error + NoSuchMethodError

    Jeferson Dal Molin Newbie

      Hello!

       

      I'm trying to test a very simple REST client using RestEasy.

      The thing is that I'm getting java.lang.NoSuchMethodError: javax.ws.rs.core.Response.getMediaType()Ljavax/ws/rs/core/MediaType;

       

      The complete log entry is as follows:

      java.lang.NoSuchMethodError: javax.ws.rs.core.Response.getMediaType()Ljavax/ws/rs/core/MediaType;
      org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:144)
      org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:444)
      org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(ClientInvocationBuilder.java:165)
      

       

      Below is my sample code:

      Client client = ClientBuilder.newBuilder().build();
        WebTarget target = client.target("http://177.10.97.155:8080/Biblioteca/biblioteca/ws_Biblioteca");
        String response = target.request().get(String.class);
        System.out.println(response)
      

       

      I've also tried to follow the steps suggested by this thread. It still doesn't work: http://stackoverflow.com/questions/24139097/resteasy-client-nosuchmethoderror

       

      My complete jboss-deployment-structure looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure >
         <deployment>
            <dependencies>
                  <module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
             </dependencies>
           <exclusions>
            <module name="javax.ws.rs.core"/>
              <module name="javax.activation.api"/>
              <module name="javax.annotation.api"/>
              <module name="javax.ejb.api"/>
              <module name="javax.el.api"/>
              <module name="javax.enterprise.api"/>
              <module name="javax.enterprise.deploy.api"/>
              <module name="javax.inject.api"/>
              <module name="javax.interceptor.api"/>
              <module name="javax.jms.api"/>
              <module name="javax.jws.api"/>
              <module name="javax.mail.api"/>
              <module name="javax.management.j2ee.api"/>
              <module name="javax.persistence.api"/>
              <module name="javax.resource.api"/>
              <module name="javax.rmi.api"/>
              <module name="javax.security.auth.message.api"/>
              <module name="javax.security.jacc.api"/>
              <module name="javax.servlet.api"/>
              <module name="javax.servlet.jsp.api"/>
              <module name="javax.transaction.api"/>
              <module name="javax.xml.bind.api"/>
              <module name="javax.xml.registry.api"/>
              <module name="javax.xml.soap.api"/>
              <module name="javax.xml.ws.api"/>
      
             <module name="org.apache.commons.logging"/>
             <module name="org.jboss.as.jaxrs"/>
             <module name="org.jboss.resteasy.resteasy-jaxrs"/>
             <module name="org.jboss.resteasy.resteasy-cdi"/>
             <module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
             <module name="org.jboss.resteasy.jackson-provider"/>
             <module name="org.jboss.resteasy.resteasy-atom-provider"/>
             <module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/>
             <module name="org.jboss.resteasy.resteasy-jaxb-provider"/>
             <module name="org.jboss.resteasy.resteasy-jettison-provider"/>
             <module name="org.jboss.resteasy.resteasy-jsapi"/>
             <module name="org.jboss.resteasy.resteasy-multipart-provider"/>
             <module name="org.jboss.resteasy.resteasy-yaml-provider"/>
             <module name="org.codehaus.jackson.jackson-core-asl"/>
             <module name="org.codehaus.jackson.jackson-jaxrs"/>
             <module name="org.codehaus.jackson.jackson-mapper-asl"/>
             <module name="org.codehaus.jackson.jackson-xc"/>
             <module name="org.codehaus.jettison"/>
             <module name="javax.ws.rs.api"/>
             
           </exclusions>
           
         </deployment>
       </jboss-deployment-structure>
      

       

      My Maven dependencies are:

      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
        <version>3.0.11.Final</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>3.0.11.Final</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson-provider</artifactId>
        <version>3.0.11.Final</version>
      </dependency>
      

       

       

      I'm deploying the application to Jboss AS 7.1.1. I've checked Jboss' default JAX-RS module, which is version 1.1. Indeed it does not contain javax.ws.rs.core.Response.getMediaType() method. On the other hand, the jar that I pointed to in my Maven dependency (resteasy-jaxrs) does have the mentioned method.

      Looks like the module javax.ws.rs.core is not being ignored, as my jboss-deployment-structure suggests, and intead, the application is calling the default jboss module.

       

      Does anyone have a clue on this one?

       

      I'm stuck on this for a couple of days now!

       

      Thanks in advance!