3

I am working on upgrading a complex maven project, with numerous pom files. The code is built using openjdk and it runs on jboss6.*

On starting up Jboss, I'm getting the following exception:

NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V

Initially, it looked like I was not importing the right maven dependency.

I looked at the pom file for the project where the exception is thrown and I found the following dependency:

<dependency>
 <groupId>org.apache.httpcomponents</groupId>
 <artifactId>httpclient</artifactId>
 <version>4.5.5</version>
</dependency>

However, when adding the following line

LOGGER.debug(org.apache.http.conn.ssl.SSLConnectionSocketFactory.class.getProtectionDomain().getCodeSource().getLocation().getPath());

I get the following output:

11:54:37,037 DEBUG [packageobsucated.httpclient.HttpClientConfigUtil] (ServerService Thread Pool -- 69) file:/server/modules/system/layers/base/org/apache/httpcomponents/main/httpclient-4.3.6.redhat-1.jar!/

How can I find out which maven dependency is using httpclient-4.3.6.redhat-1.jar?

I have called mvn dependency:tree on the parent pom.xml file but I'm afraid I cannot find anything with that exact description.

Thanks in advance,

Lucas T
  • 3,011
  • 6
  • 29
  • 36
  • 1
    If you are running in jboss, it may be that the container is providing the jar. I'm not familiar with it but the path `/server/modules/system/layers/` makes me think it is probably the container. Effectively, some library you are using is compiled against a different version of `httpclient` than the one jboss is providing. – Michael Jan 02 '20 at 13:38
  • 1
    If that is the case, you want to exclude the module from jboss á la https://stackoverflow.com/questions/47759298/jboss-eap-7-how-to-exclude-implicit-modules-from-deployment-javax-jms – Michael Jan 02 '20 at 13:42
  • 1
    @Michael Sorry, I missed your comment while I was writing the answer (no intend to copy your idea). – J Fabian Meier Jan 02 '20 at 13:49

1 Answers1

2

I am not jboss expert, but I guess that this dependency is loaded from a module inside jboss, i.e. not from your war.

So I guess you need to look for the order of class loading in your jboss if you want to use a different version of httpclient.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thank you, JF Meier and @Michael. The offending jar lives in /modules/system/layers/base/org/apache/httpcomponents/main/httpclient-4.3.6.redhat-1.jar. Kind regards – Lucas T Jan 02 '20 at 15:23