Httpclient-osgi dependency causes runtime problems


We use com.complexible.stardog:client-http:4.2.3@pom as dependency which transitively includes org.apache.httpcomponents:httpclient-osgi:4.4. The problem here is that this artifact provides the same classes as org.apache.httpcomponents:httpclient. This can lead to duplicate class files in the classpath which in turn can cause runtime errors like NoSuchMethodError if different versions of httpclient and httpclient-osgi are resolved. Currently we have to exclude this dependency to avoid such errors:

dependencies {
  compile("com.complexible.stardog:client-http:${stardogVersion}@pom") {
    transitive = true
    exclude group: 'org.apache.httpcomponents', module: 'httpclient-osgi'

The versions are managed by the Spring Boot Gradle plugin. Unfortunately, httpclient-osgi is not automatically managed.

Is there any reason to depend on the OSGi version? Would it be possible to switch to httpclient? We think this could prevent problems for others too.

Hi, thanks for the report.

We don’t see an immediate reason why the osgi dependency is there, other than a comment saying that it is needed for loading/parsing/exporting JSON-LD data. We will look further into this for the 5.x release cycle.