0 Replies Latest reply on Dec 13, 2011 4:55 AM by Michael Steffens

    ModuleClassLoader can't load HttpClient within a spring loaded bean using RESTEasy

    Michael Steffens Newbie

      Hello Community,


      I'm trying to solve a classloading issue with "chained" RESTEasy services in JBoss AS 7.0.2 Final and in JBoss AS 7.1.0 Beta1b for quite a while now, but to no avail so far.


      Attached is a downstripped maven project demonstrating the issue: Whenever I attempt to create a HttpClient from within a service, the ModuleClassLoader


      • either throws "java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.<init>(Lorg/apache/http/client/HttpClient;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, com/hp/test/ClientInServiceImpl, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/resteasy/client/core/executors/ApacheHttpClient4Executor, have different Class objects for the type org/apache/http/client/HttpClient used in the signature", if resteasy-jaxrs and its dependencies are included in the war file.
      • or, if resteasy-jaxrs and dependencies were marked "provided", thus not included in the war file, deployment fails with java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials.


      To reproduce, just deploy the restws-client-in-service.war produced by attaches source, and trigger the problem by directing a browser to




      assuming the JBoss is running on localhost. The example should return a "Sorry, host not found, but test PASSED!". However, I'm failing much earlier always in one or the other way described above.


      The attached exsample is tailored for 7.1.0.Beta1b by refrerring to RESTEasy artifact versions 2.2.3.GA, which is partially included in JBoss this version's modules. The behavior is absolutely the same as on 7.0.2 Final, when using RESTEasy 2.2.1.GA instead.


      Thanks a lot in advance for your help!


      Message was edited by: Michael Steffens Attached zip was unintentionally nested zip archive. Apologies. Replaced by fixed one.