我实际上是在尝试将 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]