Stardog 5.0 maven dependencies conflict problem?

Hi community,

I am deploying stardog 5.0 beta using maven.
However, when I run my program, it gives me the error as follows (it is the full trace of error)

Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
	at com.complexible.stardog.protocols.http.client.BaseHttpClient.<init>(BaseHttpClient.java:160)
	at com.complexible.stardog.protocols.http.client.HttpClientImpl.<init>(HttpClientImpl.java:120)
	at com.complexible.stardog.protocols.http.client.HttpConnection.create(HttpConnection.java:42)
	at com.complexible.stardog.protocols.http.client.HttpDriver.connect(HttpDriver.java:73)
	at com.complexible.stardog.api.DriverManager.getConnection(DriverManager.java:83)
	at com.complexible.stardog.api.ConnectionConfiguration.connect(ConnectionConfiguration.java:126)
	at tw.rpi.pnnl.sibench.util.SnarlClient.<init>(SnarlClient.java:51)
	at tw.rpi.pnnl.sibench.core.Window.<init>(Window.java:48)
	at tw.rpi.pnnl.sibench.window.LogicalWindow.<init>(LogicalWindow.java:31)
	at tw.rpi.pnnl.sibench.window.SlidingLogicalWindow.<init>(SlidingLogicalWindow.java:19)
	at tw.rpi.pnnl.sibench.factory.WindowFactory.createWindow(WindowFactory.java:28)
	at tw.rpi.pnnl.sibench.Launcher.run(Launcher.java:42)
	at tw.rpi.pnnl.sibench.Launcher.main(Launcher.java:38)

and my 51st line in SnarlClient code is

aQueryDBConn = ConnectionConfiguration.to(queryDBName).server(serverURL).credentials(username, password).connect();

I presume it is a conflict but the error message doesn’t really show anything.
I have attached my maven file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>tw.rpi.edu.si</groupId>
  <artifactId>sibench</artifactId>
  <version>1.2.0</version>
  <packaging>jar</packaging>

  <name>sibench</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
   
  <repositories>
    <repository>
     <id>stardog-public</id>
     <url>http://maven.stardog.com</url>
    </repository>
    <repository>
     <id>streamreasoning_repository</id>
     <name>Csparql server repository</name>
     <url>http://streamreasoning.org/maven/</url>
     <layout>default</layout>
    </repository>
    <repository>
     <id>cqels.mvn-repo</id>
     <url>https://raw.github.com/KMax/cqels/mvn-repo/</url>
     <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
     </snapshots>
    </repository>
  </repositories>
  
 <dependencies>
	<dependency>
		<groupId>org.apache.jena</groupId>
		<artifactId>jena-arq</artifactId>
		<version>2.9.3</version>
	</dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections-maven</artifactId>
      <version>0.9.9-RC2</version>
    </dependency>
 
  
    <dependency>
  	  <groupId>com.complexible.stardog</groupId>
      <artifactId>client-http</artifactId>
      <version>5.0-beta</version>
      <type>pom</type>
    </dependency>
    <dependency>
  	  <groupId>com.complexible.stardog</groupId>
      <artifactId>server</artifactId>
      <version>5.0-beta</version>
      <type>pom</type>
    </dependency>     
    <dependency>
  	  <groupId>com.complexible.stardog.sesame</groupId>
      <artifactId>stardog-sesame-core</artifactId>
      <version>5.0-beta</version>
      <type>jar</type>
    </dependency> 
    <dependency>
  	  <groupId>com.complexible.stardog.jena</groupId>
      <artifactId>stardog-jena</artifactId>
      <version>5.0-beta</version>
      <type>jar</type>
    </dependency> 
    <dependency>
  	  <groupId>com.complexible.stardog.gremlin</groupId>
      <artifactId>stardog-gremlin</artifactId>
      <version>5.0-beta</version>
      <type>jar</type>
    </dependency> 

    <dependency>
      <groupId>eu.larkc.csparql</groupId>
      <artifactId>csparql-core</artifactId>
      <version>0.9.7</version>
    </dependency>
    <dependency>
      <groupId>org.deri.cqels</groupId>
      <artifactId>cqels</artifactId>
      <version>1.0.0</version>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>1.3</version>
    </dependency>       
  </dependencies>
  
</project>

The interesting thing is that, if I include the stardog libs locally in a .classpath file, and leave other libs in the maven, the system will run perfectly.
Do you know if there is anything wrong?

Appreciate your help and time!
Robert.

What is your serverUrl? Are you using SSL/TLS?

Check that. It probably doesn’t have anything to do with SSL. Check your dependencies for httpclient and httpcore. cquels and/or csparql-core might be pulling incompatible versions in.

Thanks Zach,

My serverURL is http://localhost:5820.
I don’t use SSL/TLS.

If there is an incompatible version pulled in, what should I do? make them to choose compatible versions?

Yes, you would add an exclusion to one of the dependencies bringing in the version of the jar you don’t want (often I’d assume you would exclude the older version). You can look here and here for examples of how to find conflicts and add exclusions

Thank you Stephen and Zach,

I am able to solve the problem based on your advice.
I would like to document my solutions for other people’s reference.

  1. from the error log, I think it is the conflict about httpcomponents,
  2. I ran the following command to get the dependency tree
mvn dependency:tree -Dverbose -Dincludes=commons-httpclient

and got the following:

[INFO] +- org.apache.jena:jena-arq:jar:2.9.3:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.1.2:compile
[INFO] |  |  \- (org.apache.httpcomponents:httpcore:jar:4.1.2:compile - omitted for conflict with 4.1.3)
[INFO] |  \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
[INFO] +- com.complexible.stardog:client-http:pom:5.0-beta:compile
[INFO] |  +- com.complexible.stardog.stardocs.http:stardog-stardocs-protocols-http-client:jar:5.0-beta:compile
[INFO] |  |  +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] |  |  |  \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] |  |  \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] |  \- com.complexible.stardog.protocols.http:stardog-protocols-http-client:jar:5.0-beta:compile
[INFO] |     +- com.complexible.stardog.utils:stardog-utils-rdf:jar:5.0-beta:compile
[INFO] |     |  +- org.apache.httpcomponents:httpclient-osgi:jar:4.5.2:compile
[INFO] |     |  |  +- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] |     |  |  +- (org.apache.httpcomponents:httpmime:jar:4.5.2:compile - omitted for duplicate)
[INFO] |     |  |  +- (org.apache.httpcomponents:httpclient-cache:jar:4.5.2:compile - omitted for duplicate)
[INFO] |     |  |  \- org.apache.httpcomponents:fluent-hc:jar:4.5.2:compile
[INFO] |     |  |     \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] |     |  +- org.apache.httpcomponents:httpclient-cache:jar:4.5.2:compile
[INFO] |     |  |  \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] |     |  +- org.openrdf.sesame:sesame-rio-jsonld:jar:4.0.0:compile
[INFO] |     |  |  \- com.github.jsonld-java:jsonld-java:jar:0.7.0:compile
[INFO] |     |  |     +- (org.apache.httpcomponents:httpclient-osgi:jar:4.2.5:compile - omitted for conflict with 4.5.2)
[INFO] |     |  |     \- org.apache.httpcomponents:httpcore-osgi:jar:4.2.5:compile
[INFO] |     |  |        +- (org.apache.httpcomponents:httpcore:jar:4.2.5:compile - omitted for conflict with 4.1.3)
[INFO] |     |  |        \- org.apache.httpcomponents:httpcore-nio:jar:4.2.5:compile
[INFO] |     |  |           \- (org.apache.httpcomponents:httpcore:jar:4.2.5:compile - omitted for conflict with 4.1.3)
[INFO] |     |  \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] |     +- (org.apache.httpcomponents:httpmime:jar:4.5.2:compile - omitted for duplicate)
[INFO] |     \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO] \- com.complexible.stardog:server:pom:5.0-beta:compile
[INFO]    +- com.complexible.stardog.protocols.annex:stardog-webconsole-annex:jar:5.0-beta:compile
[INFO]    |  \- org.openrdf.sesame:sesame-repository-sparql:jar:4.0.0:compile
[INFO]    |     \- org.openrdf.sesame:sesame-http-client:jar:4.0.0:compile
[INFO]    |        \- (org.apache.httpcomponents:httpclient:jar:4.4:compile - omitted for conflict with 4.1.2)
[INFO]    +- com.complexible.stardog.virtual.http:stardog-virtual-protocols-http-server:jar:5.0-beta:compile
[INFO]    |  \- com.complexible.stardog.virtual:stardog-virtual-core:jar:5.0-beta:compile
[INFO]    |     \- org.apache.calcite:calcite-core:jar:1.11.0:compile
[INFO]    |        \- org.apache.calcite.avatica:avatica-core:jar:1.9.0:compile
[INFO]    |           +- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO]    |           \- (org.apache.httpcomponents:httpcore:jar:4.4.4:compile - omitted for conflict with 4.1.3)
[INFO]    \- com.complexible.stardog.stardocs:stardog-stardocs-core:jar:5.0-beta:compile
[INFO]       +- org.apache.tika:tika-parsers:jar:1.13:compile
[INFO]       |  +- edu.ucar:cdm:jar:4.5.5:compile
[INFO]       |  |  \- (org.apache.httpcomponents:httpcore:jar:4.2.5:compile - omitted for conflict with 4.1.3)
[INFO]       |  \- edu.ucar:httpservices:jar:4.5.5:compile
[INFO]       |     +- (org.apache.httpcomponents:httpclient:jar:4.2.6:compile - omitted for conflict with 4.1.2)
[INFO]       |     +- (org.apache.httpcomponents:httpcore:jar:4.2.5:compile - omitted for conflict with 4.1.3)
[INFO]       |     \- (org.apache.httpcomponents:httpmime:jar:4.2.6:compile - omitted for conflict with 4.5.2)
[INFO]       +- com.amazonaws:aws-java-sdk-s3:jar:1.11.1:compile
[INFO]       |  \- com.amazonaws:aws-java-sdk-core:jar:1.11.1:compile
[INFO]       |     \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
[INFO]       \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for conflict with 4.1.2)
  1. by examining the results, I think it is because jena depends on an older version of htttpcomponents. So in my pom.xml, I do the following exclusions
    <dependency>
		<groupId>org.apache.jena</groupId>
		<artifactId>jena-arq</artifactId>
		<version>2.9.3</version>
		<exclusions>
			<exclusion>
			  <groupId>org.apache.httpcomponents</groupId>
      		  <artifactId>httpclient</artifactId>      		  
			</exclusion>
			<exclusion>
			  <groupId>org.apache.httpcomponents</groupId>
			  <artifactId>httpcore</artifactId>  
			</exclusion>
		</exclusions>
	</dependency>
  1. the problem solved.

Thank you!
Robert

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.