I am trying to write simple RESTEasy client. Below given is sample code:
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target
At last after banging my head for couple of days, I could resolve these issues.
Error: "java.lang.NoSuchMethodError: org.jboss.resteasy.spi.ResteasyProviderFactory.(Lorg/jboss/resteasy/spi/ResteasyProviderFactory;)"
Solution: I resolved this issue, by adding more resteasy modules in exclusion list inside jboss-deployment-structure.xml. My current state of jboss-deployment-structure.xml is as:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
</dependencies>
<exclude-subsystems>
<subsystem name="resteasy"/>
</exclude-subsystems>
<exclusions>
<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.ws.rs.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"/>
<!-- This one always goes last. -->
<module name="javax.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"/>
<module name="javax.ws.rs.core"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
I believe, it could have worked by simply excluding modules "org.jboss.resteasy.resteasy-jaxrs" and "org.jboss.resteasy.resteasy-cdi". But I did not try further as I faced another issue. You can try by removing un-necessary exclusions.
Error: "Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response.readEntity(Ljava/lang/Class;)Ljava/lang/Object;"
Solution: JBOSS EAP 6.1, is bundled with default resteasy distribution. I downloaded latest resteasy jax-rs implementation (resteasy-jaxrs-3.0.7.Final-all.zip) from location.
It comes with zip file called resteasy-jboss-modules-3.0.7.Final.zip. Unzip this file inside modules/system/layers/base/ directory of the JBoss EAP 6.1 distribution. This will overwrite some of the existing files there. This will resolve second issue.
Hope this information would help others.
This problems are thrown cause of different version of Resteasy Client implementation between your app and Jboss EAP modules. You are using the newest version of jaxrs-client, but JBoss EAP 6.3.0 use very old version (resteasy-jaxrs-2.3.8.Final-redhat-3).
Just download latest pack of JBoss Resteasy implementation (sometking like this: resteasy-jboss-modules-3.0.9.Final.zip) and unzip into EAP Modules folder replacing existing files modules.xml and adding new jars. Remeber replace all JARS from the ZIP (not only resteasy-jaxrs).