4

I'm working on a Spring webservice(SpringWSTemplate) and I am trying to override org.springframework.ws.transport.http.HttpComponentsMessageSender and I have a code like below:

public class CustomHttpComponentsMessageSender extends
org.springframework.ws.transport.http.HttpComponentsMessageSender {
@Override
public WebServiceConnection createConnection(URI uri) throws IOException {

CookieStore cookieStore = new BasicCookieStore();
HttpComponentsConnection conn = (HttpComponentsConnection) super
.createConnection(uri);
HttpClientBuilder httpClientBuilder=HttpClientBuilder.create();
HttpClient httpclient = httpClientBuilder.setDefaultCookieStore(cookieStore).build();
HttpPost httpGet = new HttpPost(uri);
HttpResponse response = httpclient.execute(httpGet);
return conn;
}

}

When the code execution reaches line : HttpClient httpclient = httpClientBuilder.setDefaultCookieStore(cookieStore).build();

I get the following exception

INFO   | jvm 1    | main    | 2015/03/12 14:48:41.707 | Mar 12, 2015 2:48:41 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.709 | SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory] with root cause
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.709 | java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:487)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:147)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:136)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:112)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at com.utas.integrations.documentum.webservices.impl.CustomHttpComponentsMessageSender.createConnection(CustomHttpComponentsMessageSender.java:30)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.springframework.ws.client.support.WebServiceAccessor.createConnection(WebServiceAccessor.java:107)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:535)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:386)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:380)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:372)
INFO   | jvm 1    | main    | 2015/03/12 14:48:41.710 |     at 

I use the jars in my build path and I have entries of jars in my classpath.

<classpathentry kind="lib" path="lib/httpclient-4.3.3.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
<classpathentry kind="lib" path="/sapadtreco/lib/httpmime-4.3.1.jar"/>
<classpathentry kind="lib" path="lib/spring-ws-core-2.1.4.RELEASE.jar"/>
<classpathentry kind="lib" path="lib/fluent-hc-4.3.jar"/>

Quick help is greately appreciated.

1
  • 1
    Hi, did you get a solution? I have the same issue, also when I try exploding the jar , I see that the class file it is looking for is already present. Commented Aug 26, 2015 at 18:32

1 Answer 1

3

It could be due to the invalid/corrupt/missing httpclient-4.3.3.jar file in the class path. Try exploding this file and check if its valid and contains the ManagedHttpClientConnectionFactory class inside it.

Sign up to request clarification or add additional context in comments.

1 Comment

actually it is not that ManagedHttpClientConnectionFactory is missing - it cannot be initialized. had to look inside code to understand what was going on. to make the long story short, in my case, my application was referencing an uber-jar where a reference to an older version of httpcore library had crept, and although i referenced a later version in my main app, that older reference was picked up stackoverflow.com/questions/21864521/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.