Alternator icon indicating copy to clipboard operation
Alternator copied to clipboard

Need to add slf4j dependency in Alternator pom.xml

Open inder123 opened this issue 13 years ago • 9 comments

I added Alternator per the instructions in your readme. However, when I attempt to start the Alternator server, I ran into an exception (see below). It seems to me that you need to specify an additional dependency in your pom.xml?

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:613) at org.eclipse.jetty.util.log.JettyAwareLogger.debug(JettyAwareLogger.java:200) at org.eclipse.jetty.util.log.Slf4jLog.debug(Slf4jLog.java:84) at org.eclipse.jetty.util.component.Container.add(Container.java:201) at org.eclipse.jetty.util.component.Container.update(Container.java:164) at org.eclipse.jetty.util.component.Container.update(Container.java:106) at org.eclipse.jetty.server.Server.setConnectors(Server.java:183) at org.eclipse.jetty.server.Server.addConnector(Server.java:157) at com.michelboudreau.alternator.AlternatorDB.(AlternatorDB.java:41) at com.michelboudreau.alternator.AlternatorDB.(AlternatorDB.java:24) at com.trymph.user.server.persistence.DynamoDBMapperUserTest.setUp(DynamoDBMapperUserTest.java:27) at junit.framework.TestCase.runBare(TestCase.java:128) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

inder123 avatar Aug 30 '12 17:08 inder123

These additional dependencies did the trick for me:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.6.6</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>log4j-over-slf4j</artifactId>
  <version>1.6.6</version>
</dependency>

The issue is discussed in: http://stackoverflow.com/questions/7165633/exception-thrown-while-using-logback-slf4j

inder123 avatar Aug 30 '12 17:08 inder123

Are you having this problem in the alternator project itself or in the app running it?

mboudreau avatar Aug 30 '12 18:08 mboudreau

Was missing the log4j-over-slf4j dependency in pom file. It was working in our application because dependency was already present. Fixed in 0.2.7-SNAPSHOT.

mboudreau avatar Aug 30 '12 19:08 mboudreau

I had this problem in my project, not in Alternator.

inder123 avatar Aug 30 '12 19:08 inder123

Let me try it out in a new project to test it out.

mboudreau avatar Aug 30 '12 19:08 mboudreau

Are you sure you incremented the version number to 0.2.7-SNAPSHOT? I just tried it on a new project which it started and stopped without issue.

mboudreau avatar Aug 30 '12 20:08 mboudreau

yes, I tried it with 0.2.7-SNAPSHOT. I am able to continue forward by adding those dependencies in my pom.xml as well, so it is not a blocker for me. This was mainly FYI. Thanks.

inder123 avatar Aug 30 '12 21:08 inder123

I can't reproduce this error at all, if you can provide me with a small project that creates the error, I can find out what's the cause.

mboudreau avatar Aug 30 '12 21:08 mboudreau

I think the following two dependencies should be scoped to test instead of runtime or compile. Only slf4j-api dependency should be set to compile.

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.0</version>
    </dependency>

Based on the guidelines in this doc: http://veithen.blogspot.com/2009/10/taming-beast-managing-slf4j.html

inder123 avatar Sep 07 '12 23:09 inder123