0

我正在尝试配置一个播放应用程序以使用 Kamon。我创建了一个新的播放应用程序

activator new kamon-play play-scala

然后我把它贴在了 github 上。我在 OS X 10.11.1 上运行,并且正在运行 JDK 1.8.0_65-b17,并且该项目配置了 scala 2.11.6。我已经根据配置 Play 的说明以及 sbt-aspectj-runner kamon-play 示例对其进行了配置(据我所知) 。但是,当我尝试使用以下任一方式运行应用程序时:

sbt run

或者

activator run

我收到以下错误:

[ERROR] [11/25/2015 09:04:39.574] [ForkJoinPool-1-worker-9] [ModuleLoader(akka://kamon)] 

  ___                           _      ___   _    _                                 ___  ___ _            _
 / _ \                         | |    |_  | | |  | |                                |  \/  |(_)          (_)
/ /_\ \ ___  _ __    ___   ___ | |_     | | | |  | |  ___   __ _ __   __ ___  _ __  | .  . | _  ___  ___  _  _ __    __ _
|  _  |/ __|| '_ \  / _ \ / __|| __|    | | | |/\| | / _ \ / _` |\ \ / // _ \| '__| | |\/| || |/ __|/ __|| || '_ \  / _` |
| | | |\__ \| |_) ||  __/| (__ | |_ /\__/ / \  /\  /|  __/| (_| | \ V /|  __/| |    | |  | || |\__ \\__ \| || | | || (_| |
\_| |_/|___/| .__/  \___| \___| \__|\____/   \/  \/  \___| \__,_|  \_/  \___||_|    \_|  |_/|_||___/|___/|_||_| |_| \__, |
            | |                                                                                                      __/ |
            |_|                                                                                                     |___/

 It seems like your application was not started with the -javaagent:/path-to-aspectj-weaver.jar option but Kamon detected
 the following modules which require AspectJ to work properly:

      kamon-akka, kamon-scala, kamon-play

 If you need help on setting up the aspectj weaver go to http://kamon.io/introduction/get-started/ for more info. On the
 other hand, if you are sure that you do not need or do not want to use the weaver then you can disable this error message
 by changing the kamon.show-aspectj-missing-warning setting in your configuration file.

我已经尝试了以下所有方法:

  • 添加aspectj-play-runner:run到 plugins.sbt 文件(不编译)

  • 将 javaagent 参数传递给激活器:

    activator -J-javaagent::~/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.5.jar

但这会导致以下错误:

Error opening zip file or JAR manifest missing : :~/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.5.jar
Error occurred during initialization of VM
agent library failed to init: instrument
  • 将 javaagent 参数传递给 sbt:

    sbt run -Djavaagent:~/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.5.jar

也试过

sbt run -Djavaagent:~/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.5.jar -Daspectj-play-runner:run

更新

我发现 aspectj-play-runner:run 是一个 sbt 任务/命令,所以我尝试了:

sbt
aspectj-runner:run

输出:

[WeavingURLClassLoader] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
java.lang.RuntimeException: Kamon has not been started yet. You must either explicitlt call Kamon.start(...) or enable automatic startup by adding -Dkamon.auto-start=true to your JVM options.

所以我尝试了:

sbt -Dkamon.auto-start=true
aspectj-runner:run

哪个输出:

[WeavingURLClassLoader] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
com.typesafe.config.ConfigException$IO: application.conf: java.io.IOException: resource not found on classpath: application.conf

最后,文件实际上说我应该跑步

sbt
aspectj-play-runner:run

但是甚至无法识别命令/任务。

4

2 回答 2

1

我可以在推特上联系@kamonteam,这是他们的回复:

@dvMENTALmadness 目前我们在一起使用 akka 和 play 模块时在 kamon 中有一个错误,直到我们希望在下一个版本中发布......现在唯一的选择是删除 kamon-akka 模块:(

基于此,我从 build.sbt 和 application.config 中删除了对 kamon-akka 模块的引用,现在它可以工作了。一旦我从项目中遇到问题,我会跟踪它并在问题解决后发布。与此同时,这是为我“解决”问题的提交。但是,我仍然需要 akka 模块,因为它对我来说是一个完整的解决方案。

于 2015-11-26T14:23:41.423 回答
0

一种解决方法是设置 JAVA_OPTS 环境变量。

export JAVA_OPTS="-javaagent:$HOME/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.10.jar"
sbt run
于 2017-03-22T23:25:04.587 回答