Reputation: 21
I am trying to consume a soap webservice and included the relative dependency in gradle file as
implementation('org.springframework.boot:spring-boot-starter-web-services') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
along with Jaxb dependencies. This code works absolutely fine in my local and I am able to retrieve the results from the service, but when I deploy this code to Openshift, I am getting below error:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com..abc.xyz.AccountServiceClient]: Factory method 'accountServiceClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar!/:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar!/:5.3.22]
... 69 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager
at com.discover.card.collections.aprapi.config.WebServiceConfig.httpComponentsMessageSender(WebServiceConfig.java:43) ~[classes!/:na]
at com.discover.card.collections.aprapi.config.WebServiceConfig.accountServiceClient(WebServiceConfig.java:31) ~[classes!/:na]
at com.discover.card.collections.aprapi.config.WebServiceConfig$$EnhancerBySpringCGLIB$$79bdd48b.CGLIB$accountServiceClient$1(<generated>) ~[classes!/:na]
I have tried to add the dependency for HttpClient and
implementation("org.apache.httpcomponents:httpclient:4.5.3")
implementation "org.apache.cxf:cxf-rt-transports-http-hc:3.4.2"
but it is still not working.
Tried searching as well, but didn't see anybody else facing similar scenario where it works fine in local, but throws error while deploying in openshift.
I am using same yaml profile for both local and dev, so that should also not be the issue.
Pls advise what else can I look out for?
Upvotes: 2
Views: 407
Reputation: 1177
While migrating to spring 6 / springboot 3 I came accross the same exception. Not sure it exacly the problem encountered here but here how it was fixed. Our exception:
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.ClientConnectionManager at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at
ava.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
... 85 more
Turns out it was because we were using HttpComponentsMessageSender, upgrading to HttpComponents5MessageSender fix the problem
original code:
HttpComponentsMessageSender sender() {
return new HttpComponentsMessageSender();
}
become:
HttpComponents5MessageSender sender() {
return new HttpComponents5MessageSender();
}
And the exception no longer happened.
Upvotes: 0