我实际上是在尝试将Kamon 0.4.0与我的play(scala)应用程序集成在一起(顺便提一下很棒的框架!)。
这是我做的:
在我的 build.sbt 中添加了以下依赖项:
libraryDependencies ++= Seq(
jdbc,
anorm,
"com.typesafe.play" %% "play-mailer" % "2.4.0",
"org.bouncycastle" % "bcpkix-jdk15on" % "1.51",
"org.bouncycastle" % "bcprov-jdk15on" % "1.51",
"com.github.nscala-time" %% "nscala-time" % "1.8.0",
"io.kamon" %% "kamon-core" % "0.4.0",
"io.kamon" %% "kamon-play" % "0.4.0",
"org.aspectj" % "aspectjweaver" % "1.8.6"
)
在Global.scala中启动和关闭Kamon:
object Global extends GlobalSettings {
override def onStart(app: Application) {
val hsmProxyName = Play.current.configuration.getString("ngocspd.hsm.proxy.name").get
val supervisorName = Play.current.configuration.getString("ngocspd.ocspd.supervisor.name").get
val notifierName = Play.current.configuration.getString("ngocspd.notification.name").get
java.security.Security.addProvider(new BouncyCastleProvider)
// Starting Kamon
Kamon.start()
Akka.system.actorOf(Props[NotificationActor], name = notifierName)
Akka.system.actorOf(Props[HardwareSecurityModuleProxyActor], name = hsmProxyName)
Akka.system.actorOf(Props[OCSPdActor], name = supervisorName)
}
override def onStop(app: Application) {
Kamon.shutdown()
}
}
使用AspectJ代理的路径启动激活器:
activator -J-javaagent:/Users/pantin/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.6.jar
我遇到两个问题。
运行应用程序时,会抛出以下异常:
[error] o.a.w.b.BcelWorld - Unable to find class 'scala.concurrent.impl.Future.PromiseCompletingRunnable' in repository
java.lang.ClassNotFoundException: scala.concurrent.impl.Future.PromiseCompletingRunnable not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'scala.concurrent.impl.Future.PromiseCompletingRunnable' in repository
java.lang.ClassNotFoundException: scala.concurrent.impl.Future.PromiseCompletingRunnable not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'scala.concurrent.impl.Future.PromiseCompletingRunnable' in repository
java.lang.ClassNotFoundException: scala.concurrent.impl.Future.PromiseCompletingRunnable not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'scala.concurrent.impl.Future.PromiseCompletingRunnable' in repository
java.lang.ClassNotFoundException: scala.concurrent.impl.Future.PromiseCompletingRunnable not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'scala.concurrent.impl.Future.PromiseCompletingRunnable' in repository
java.lang.ClassNotFoundException: scala.concurrent.impl.Future.PromiseCompletingRunnable not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'scala.concurrent.impl.Future.PromiseCompletingRunnable' in repository
java.lang.ClassNotFoundException: scala.concurrent.impl.Future.PromiseCompletingRunnable not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.event.Logging.LogEvent' in repository
java.lang.ClassNotFoundException: akka.event.Logging.LogEvent not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.event.Logging.LogEvent' in repository
java.lang.ClassNotFoundException: akka.event.Logging.LogEvent not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.event.Logging.LogEvent' in repository
java.lang.ClassNotFoundException: akka.event.Logging.LogEvent not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.event.Logging.LogEvent' in repository
java.lang.ClassNotFoundException: akka.event.Logging.LogEvent not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
[error] o.a.w.b.BcelWorld - Unable to find class 'akka.dispatch.Dispatcher.LazyExecutorServiceDelegate' in repository
java.lang.ClassNotFoundException: akka.dispatch.Dispatcher.LazyExecutorServiceDelegate not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292) ~[aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:418) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:392) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107) [aspectjweaver-1.8.6.jar:1.8.6]
at org.aspectj.weaver.World.resolveToReferenceType(World.java:477) [aspectjweaver-1.8.6.jar:1.8.6]
有没有办法摆脱这些例外?
然后,应用程序崩溃了以下堆栈跟踪:
play.api.UnexpectedException: Unexpected exception[ConfigurationException: Could not start logger due to [akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.Logging$DefaultLogger] due to [java.lang.RuntimeException: Cannot retrieve extensions while Kamon is being initialized.]]]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.11-2.3.8.jar:2.3.8]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.8.jar:2.3.8]
at scala.Option.map(Option.scala:146) ~[scala-library-2.11.6.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.8.jar:2.3.8]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:128) ~[play_2.11-2.3.8.jar:2.3.8]
Caused by: akka.ConfigurationException: Could not start logger due to [akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.Logging$DefaultLogger] due to [java.lang.RuntimeException: Cannot retrieve extensions while Kamon is being initialized.]]
at akka.event.LoggingBus$class.startDefaultLoggers(Logging.scala:144) ~[akka-actor_2.11-2.3.9.jar:na]
at akka.event.EventStream.startDefaultLoggers(EventStream.scala:26) ~[akka-actor_2.11-2.3.9.jar:na]
at akka.actor.LocalActorRefProvider.init(ActorRefProvider.scala:622) ~[akka-actor_2.11-2.3.9.jar:na]
at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:619) ~[akka-actor_2.11-2.3.9.jar:na]
at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:616) ~[akka-actor_2.11-2.3.9.jar:na]
答案 0 :(得分:0)
https://groups.google.com/forum/#!topic/kamon-user/Wz1hVypO15E的回复很有帮助。
而不是使用激活器运行以在开发模式下运行播放应用程序,运行sbt阶段后我使用
target/universal/stage/bin/my-app -J-javaagent:fullPathToAspectJ/aspectjweaver-1.8.5.jar
请注意,使用激活器启动不起作用。
答案 1 :(得分:-1)
有一个允许在sbt中执行LTW的sbt插件,我们将能够无缝地在开发模式下运行。 sbt-aspectj-runner