如何将Typesafe控制台与现有的Maven Akka应用程序集成?

时间:2013-11-19 13:49:27

标签: scala maven console akka typesafe

我有一个使用Maven / Java / Scala实现的Akka应用程序,现在我想将它与Typesafe Console集成。因此,我下载了完整的二进制发行版here,它很好地包含了一个示例Maven项目。但是,将更改集成到我的项目后,它不起作用。

我首先得到以下内容:

[WARN] [11/19/2013 14:36:11.047] [xxx.MapReduceNode.main()] [EventStream(akka://MapReduceNode)] [akka.event-handlers] config is deprecated, use [akka.loggers]

意味着akka.event-handlers已被弃用?但我正在使用建议的Scala版本,Atoms trace等。当前文档还建议使用akka.event-handlers查看here

在此警告旁边,我得到了erorr

[ERROR] [11/19/2013 14:36:11.074] [MapReduceNode-akka.actor.default-dispatcher-3] [ActorSystem(MapReduceNode)] Uncaught error from thread [MapReduceNode-akka.actor.default-dispatcher-3] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled
java.lang.NoClassDefFoundError: com/typesafe/atmos/trace/Tracer$
    at com.typesafe.atmos.trace.Slf4jTraceContextEventHandler$$anonfun$addContext$1.applyOrElse(Slf4jTraceContextEventHandler.scala:17)
    at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:184)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498)
    at akka.actor.ActorCell.invoke(ActorCell.scala:456)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237)
    at akka.dispatch.Mailbox.run(Mailbox.scala:219)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.ClassNotFoundException: com.typesafe.atmos.trace.Tracer$
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 11 more
鉴于Maven项目编译良好,这是非常令人震惊的。这似乎是依赖版本冲突。我进一步调查并使用mvn depencency:tree我发现我的项目依赖项中没有版本冲突。

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ hpcmom-mapreduce ---
[INFO] xxx:hpcmom-mapreduce:jar:1.0-SNAPSHOT
[INFO] +- xxx:hpcmom-commons:jar:1.0-SNAPSHOT:compile
[INFO] +- org.scala-lang:scala-library:jar:2.10.2:compile
[INFO] +- com.typesafe.atmos:trace-akka-2.1.4:jar:1.3.1:compile
[INFO] +- com.typesafe.akka:akka-actor_2.10:jar:2.2.3:compile
[INFO] |  \- com.typesafe:config:jar:1.0.2:compile
[INFO] +- com.typesafe.akka:akka-remote_2.10:jar:2.2.3:compile
[INFO] |  +- io.netty:netty:jar:3.6.6.Final:compile
[INFO] |  +- com.google.protobuf:protobuf-java:jar:2.4.1:compile
[INFO] |  \- org.uncommons.maths:uncommons-maths:jar:1.2.2a:compile
[INFO] +- com.typesafe.akka:akka-kernel_2.10:jar:2.2.3:compile
[INFO] +- com.typesafe.akka:akka-agent_2.10:jar:2.2.3:compile
[INFO] |  \- org.scala-stm:scala-stm_2.10:jar:0.7:compile
[INFO] +- com.typesafe.akka:akka-zeromq_2.10:jar:2.2.3:compile
[INFO] |  \- org.zeromq:zeromq-scala-binding_2.10:jar:0.0.7:compile
[INFO] |     +- net.java.dev.jna:jna:jar:3.0.9:compile
[INFO] |     \- com.github.jnr:jnr-constants:jar:0.8.2:compile
[INFO] +- com.typesafe.akka:akka-slf4j_2.10:jar:2.2.3:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- com.google.guava:guava:jar:15.0:compile
[INFO] +- org.scalatest:scalatest_2.10:jar:2.0.M8:test
[INFO] \- junit:junit:jar:4.11:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test

1 个答案:

答案 0 :(得分:1)

我看到的第一件事是你的追踪工件与你的Akka版本不符。从你的树上我可以看到你正在使用Akka 2.2.3:

[INFO] +- com.typesafe.akka:akka-kernel_2.10:jar:2.2.3:compile

但你的追踪罐适用于Akka 2.1

[INFO] +- com.typesafe.atmos:trace-akka-2.1.4:jar:1.3.1:compile

从这里开始:http://resources.typesafe.com/docs/console/manual/getting-started.html#instrumentation

你追踪Akka的工件应该是:

<dependency>
  <groupId>com.typesafe.atmos</groupId>
  <artifactId>trace-akka-2.2.1_2.10</artifactId>
  <version>1.3.1</version>
</dependency>

是的,在Akka 2.2中,日志配置已更改:http://doc.akka.io/docs/akka/2.2.3/scala/logging.html

要使用您需要的控制台记录器:

loggers = ["com.typesafe.atmos.trace.Slf4jTraceContextLogger"]