I try to use the IMPINJ Octane SDK Java which comes as a jar including all needed dependencies together with Spark Framework in a maven project. To include the Spark Framework I use maven and the Octane SDK jar is added to the build path. My pom.xml has only the spark dependency:
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.5</version>
</dependency>
Every time I try to run the program I get to following error.
Exception in thread "Thread-1" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;[Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:619)
at org.eclipse.jetty.util.log.JettyAwareLogger.info(JettyAwareLogger.java:314)
at org.eclipse.jetty.util.log.Slf4jLog.info(Slf4jLog.java:74)
at org.eclipse.jetty.util.log.Log.initialized(Log.java:186)
at org.eclipse.jetty.util.log.Log.getLogger(Log.java:298)
at org.eclipse.jetty.util.log.Log.getLogger(Log.java:288)
at org.eclipse.jetty.util.component.AbstractLifeCycle.<clinit>(AbstractLifeCycle.java:35)
at spark.embeddedserver.jetty.EmbeddedJettyFactory.create(EmbeddedJettyFactory.java:34)
at spark.embeddedserver.EmbeddedServers.create(EmbeddedServers.java:57)
at spark.Service.lambda$init$0(Service.java:342)
at java.lang.Thread.run(Thread.java:745)
The Octane SDK comes with slf4j and the Spark Framework also has slf4j as a dependency but they have different versions. I found the following thread NoSuchMethodError with SLF4J API but since I could remove slf4j from the jar I can't resolve the problem. How can I get this working?
I also tried to exclude slf4j in the pom but it did not work either:
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.5</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
EDIT (SOLUTION): I extracted the Octane SDK jar, removed slf4j and compressed it back to a jar.
My understanding is that sparks requires slf4j 1.7.13. Then, you add Octane to the classpath (not through a maven dependency) and this Octane jar contains older classes of slf4j.
I just downloaded Octane to see for myself. I notice it include 2 versions:
You need to use OctaneSDKJava-1.22.0.30.jar and manually include all other dependencies but NOT the slf4j one (or the opposite, use OctaneSDKJava-1.22.0.30-jar-with-dependencies.jar and remove slf4j).
I opened the latest OctaneSDKJava-1.26.2.0-jar-with-dependencies.zip, which contains a README.txt with the following details:
DEPENDENCIES
RUNTIME DEPENDENCIES
- jdom 1.0 http://www.jdom.org
- log4j 1.2.15 http://logging.apache.org/log4j/1.2/download.html
- jargs 1.0 http://sourceforge.net/project/showfiles.php?group_id=33024
- mina 1.1.7 http://mina.apache.org
- slf4j-log4j12 1.5.0 http://www.slf4j.org
- slf4j-api 1.5.0 http://www.slf4j.org
- xerces-j 2.4.0 http://xerces.apache.org/
COMPILE DEPENDENCIES
- velocity-dep 1.5 http://velocity.apache.org
- jalopy 0.3.1 http://jalopy.sourceforge.net
- jdom 1.0 http://www.jdom.org
- log4j 1.2.15 http://logging.apache.org/log4j/1.2/download.html
- commons-collection 3.2 http://commons.apache.org
- commons-configuration 1.5 http://commons.apache.org
- commons-lang 2.3 http://commons.apache.org
- common-logging 1.1.1 http://commons.apache.org
JAXB RI dependencies including:
- jaxb-xjc 2.0 https://jaxb.dev.java.net/
- jaxb-impl 2.0 https://jaxb.dev.java.net/
- jaxb-api 2.0 https://jaxb.dev.java.net/
- activation 2.0 https://jaxb.dev.java.net/
- jsr173_1.0_api 2.0 https://jaxb.dev.java.net/
The five above jaxb dependencies are available in a single jar "JAXB RI" from https://jaxb.dev.java.net/. Execute this jar (doubleclick windows, "java -jar " all other platforms) and copy the individual jars to the LTKJava/lib directory) plus above runtime dependencies
TEST DEPENDENCIES
- JUnit 4.4 http://sourceforge.net/project/showfiles.php?group_id=15278 plus above dependencies note that the junit dependency needs to be placed in the ANT_HOME/lib directory