1

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.

Community
  • 1
  • 1
rabenhorst
  • 73
  • 1
  • 5

1 Answers1

0

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:

  • OctaneSDKJava-1.22.0.30.jar
  • OctaneSDKJava-1.22.0.30-jar-with-dependencies.jar

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).


EDIT to answer a question in the comments:

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

COMPILE DEPENDENCIES

JAXB RI dependencies including:

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

alexbt
  • 16,415
  • 6
  • 78
  • 87
  • `[INFO] \- com.sparkjava:spark-core:jar:2.5:compile [INFO] \- org.slf4j:slf4j-api:jar:1.7.13:compile` this is the ouput. I extracted the octane SDK Jar and found slf4j 1.5.0 – rabenhorst Jun 30 '16 at 16:23
  • oh I see.. Octane is not added to the classpath as a dependency. And it comes with its own jars... So your problem/solution is rather at runtime, not build time.. – alexbt Jun 30 '16 at 16:28
  • Thank you for your answer. I'm trying this at the moment. – rabenhorst Jun 30 '16 at 16:39
  • @alexbt - do you have a list of the other dependencies that the octane sdk needs? – emeraldjava Apr 20 '17 at 15:27