1

I have a scala project that compiles and can be executed without errors. I added diameter dependency in my module's build.sbt file:

libraryDependencies ++= Seq(
    // some other dependencies here
    // then diameter dependencies
    "org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106",
    "org.mobicents.diameter" % "jdiameter-impl" % "1.7.0.106"
)

The project still compiles but can't run:

[app] $ compile
[success] Total time: 1 s, completed Sep 28, 2016 2:54:36 PM
[app] $ run

SLF4J: Class path contains multiple SLF4J bindings.

--- (Running the application, auto-reloading is enabled) ---

log4j:WARN No appenders could be found for logger (akka.event.slf4j.Slf4jLogger).
log4j:WARN Please initialize the log4j system properly.
java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
    at org.slf4j.bridge.SLF4JBridgeHandler.callLocationAwareLogger(SLF4JBridgeHandler.java:221)
    at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:297)
    at java.util.logging.Logger.log(Logger.java:738)
    at java.util.logging.Logger.doLog(Logger.java:765)
    at java.util.logging.Logger.logp(Logger.java:930)
    at org.jboss.netty.logging.JdkLogger.debug(JdkLogger.java:36)
    at org.jboss.netty.channel.socket.nio.SelectorUtil.<clinit>(SelectorUtil.java:57)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.getMaxThreads(NioServerSocketChannelFactory.java:248)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.<init>(NioServerSocketChannelFactory.java:115)
    at play.core.server.NettyServer.play$core$server$NettyServer$$newBootstrap(NettyServer.scala:46)
    at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:130)
    at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:129)
    at scala.Option.map(Option.scala:146)
    at play.core.server.NettyServer.<init>(NettyServer.scala:129)
    at play.core.server.NettyServerProvider.createServer(NettyServer.scala:200)
    at play.core.server.NettyServerProvider.createServer(NettyServer.scala:199)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:208)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:61)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
    at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
    at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at play.runsupport.Reloader$.startDevMode(Reloader.scala:223)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last app/compile:run for the full output.
[error] (app/compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 2 s, completed Sep 28, 2016 2:54:42 PM

I don't understand how adding those two dependencies could break the application. I can see the downloaded jars in the .ivy2 cache so the new dependencies were resolved.

How can I fix this? The full output says:

java.lang.reflect.InvocationTargetException

Many thanks for your help


Update

If I add this dependency only

"org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106"

it works :)

but I need both :(

marie
  • 457
  • 8
  • 27

1 Answers1

1

It looks like both dependencies add their own logger implementations, and they clash at runtime.

Try excluding it from one of the two, for example:

libraryDependencies ++= Seq(
    "org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106",
    "org.mobicents.diameter" % "jdiameter-impl" % "1.7.0.106" exclude("org.slf4j", "slf4j-jdk14")
)
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
  • Thanks for your help, I tried but this is not better (clean-files, then compile with success but run failed) – marie Sep 28 '16 at 13:51
  • @marcesso - you will need to clean up the transitive dependencies as per Gabriele (using the exclude). Check which libraries are being added in your build for confirmation. – ali haider Sep 28 '16 at 16:13