2 Replies Latest reply on Dec 6, 2011 9:09 AM by Jérémy Bogatirsky

    Use of httpclient-cache with Seam REST 3

    Jérémy Bogatirsky Newbie

      Hi all,

      I'm trying to use httpclient-cache in Resteasy through Seam Rest 3, by overriding the ClientExecutor has explained here.

      My code looks like this :

      public class CachingHttpClientExecutorProducer {
          public ClientExecutor createExecutor()
              HttpParams params = new BasicHttpParams();
              SchemeRegistry schemeRegistry = new SchemeRegistry();
              schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
              schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
              ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
              HttpClient defaultHhttpClient = new DefaultHttpClient(cm, params);
              HttpClient cachingHttpClient = new CachingHttpClient(defaultHhttpClient);
              return new ApacheHttpClient4Executor(cachingHttpClient);

      My problem is that I use the resteasy deployer included in JBoss 6 (resteasy-2.1.0.GA) which depends on httpclient-4.0.3 while I httpclient-cache is in version 4.1 (and depends on httpclient-4.1).

      Here is the stack trace I get when starting JBoss (class loader problem) :

      Caused by: 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/classloader/spi/base/BaseClassLoader) of the current class, my/company/CachingHttpClientExecutorProducer, 
      and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) 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
           at my.company.CachingHttpClientExecutorProducer.createExecutor(CachingHttpClientExecutorProducer.java:35) [:]

      Does someone has a solution ? Removing httpclient from resteasy deployers has no effect.

      Thanks in advance.