0

I have wrote below code

public static ResteasyClient getRestClient() {
    if (null == client) {
      client = new ResteasyClientBuilder().build();
    }
    return client;
}

But end with below error.

20:43:17,370 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/mdf-portal-web].[FacesServlet]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NoSuchMethodError:
org.jboss.resteasy.spi.ResteasyProviderFactory.<init>(Lorg/jboss/resteasy/spi/ResteasyProviderFactory;)V
    at org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration.<init>(ClientConfiguration.java:44) [resteasy-client-3.0.8.Final.jar:]
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:317) [resteasy-client-3.0.8.Final.jar:]
    at com.alu.ipprd.mdf.soa.portal.integration.rest.Constants.<clinit>(Constants.java:200) [mdf-portal-integration-0.0.1-SNAPSHOT.jar:]
    at com.alu.ipprd.bsm.soa.portal.bean.LoginBean.doLogin(LoginBean.java:897) [classes:]
    at com.alu.ipprd.bsm.soa.portal.bean.LoginBean.verifyLogged(LoginBean.java:1150) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_79]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_79]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_79]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.10.Final.jar:]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.10.Final.jar:]
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2464) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2116) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:288) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)[jbossweb-7.0.10.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_79]

Used version Jboss7.0.1.Final,JSF2.0

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>3.0.8.Final</version>
</dependency>
<!-- JAXB support -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxb-provider</artifactId>
    <version>3.0.8.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>jaxrs-api</artifactId>
    <version>3.0.8.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.8.Final</version>
</dependency>

Can someone tell me What can be issue I checked RESTEasy Client + NoSuchMethodError but did not get any help.

Jars

enter image description here

Community
  • 1
  • 1
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
  • 1
    You are trying to use RESTeasy 3.0.8 which is very different from 2.3.x, which is the version that JBoss 7 already uses. You need to search how to upgrade RESTeasy in JBoss 7 if you want to use a newer version. Or use an older version – Paul Samsotha Jan 09 '16 at 15:37
  • Jboss Version i cannot check better i have to check how to update. – Subodh Joshi Jan 09 '16 at 15:41
  • @peeskillet I excluded some of the default resteasy jar but now i am getting http://stackoverflow.com/questions/34713258/java-lang-classcastexceptionjboss-resteasy-logging Any Idea? – Subodh Joshi Jan 11 '16 at 04:27
  • I saw the question. But the way you are trying to use a different version is not something I have tried. The way I was able to update RESTeasy, was by explicitly changing jars and configurations directly in the server. This was not a hack, but something I found in some official documentation. I forgot where I found that. I was looking for it when I first saw this question, but was never able to find it. Maybe the way you are trying to do will work, but it's not something I have ever done before, though it looks familiar from when I was also searching to update. Sorry I can't be of more help – Paul Samsotha Jan 11 '16 at 04:32
  • Ok, I think I found it. Download the [RESTeasy distribution](http://resteasy.jboss.org/docs.html). Unzip it and look at the readme in the examples/oauth2-as7-example. I _think_ all you need to do is follow step 1. All the other steps are fore configuration for the example application so I don't think you need to worry about it. But note that this replaces all the original JAX-RS jars (modules), so I don't know if that's something you are allowed to do. – Paul Samsotha Jan 11 '16 at 04:45
  • @peeskillet Thanks for your reply Any how i have to use 3.0.8 jar because server is using this only only.But one question even after adding 3.0.8 jar in my project why its referring old jar while what ever war deployed it have latest jar? – Subodh Joshi Jan 11 '16 at 05:21
  • It's really the classloading. You can have the same jars, but you can only have one version of a class that is loaded. Most likely the older version is the one that gets loaded instead of the new one. This is why we need to disable (remove) the old one, so it doesn't get loaded. So you can have some classes from the new version that are loaded, and they try to use older versions of some other class. That is the usual cause of a NoSuchMethodError. The newer version is trying to call a method that doesn't exist in the older version. – Paul Samsotha Jan 11 '16 at 05:25
  • So it mean old jar are not the part of web.war/lib folder but its refereeing at run time or class loading time? – Subodh Joshi Jan 11 '16 at 05:29
  • 1
    Yes, they get loaded by JBoss. From your other question, you are showing how to disable the old module from loading, but honestly I cannot explain why it isn't working. Like I said I have never tried that before. – Paul Samsotha Jan 11 '16 at 05:30
  • @peeskillet After replacing all jar i am getting java.lang.LinkageError: Failed to link org/jboss/resteasy/client/jaxrs/internal/ClientConfiguration – Subodh Joshi Jan 11 '16 at 08:29
  • Did you manually replace them, or did you just unzip the resteasy-jboss-modules inside the modules directory, like stated in the readme? Also if you did the latter, did you change your maven dependencies to provided? – Paul Samsotha Jan 11 '16 at 08:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/100346/discussion-between-subodh-joshi-and-peeskillet). – Subodh Joshi Jan 11 '16 at 08:34

0 Answers0