kamon akka 2.4抛出java.lang.VerifyError

时间:2016-06-27 15:17:31

标签: java akka aspectj akka-monitoring

我正在使用Kamon版本0.6.1和akka 2.4.6以及scala 2.11.8。我已经在我的application.conf中完成了必要的配置,我正在使用javaagent启动我的应用程序。但是我得到了一个java.lang.VerifyError。

以下是我的详细信息

的pom.xml

<properties>
        <akka.version>2.4.6</akka.version>
        <slf4j.version>1.7.6</slf4j.version>
        <log4j.version>2.0-rc1</log4j.version>
        <slf4j.api.version>1.7.7</slf4j.api.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-cluster_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>

        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>

        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-cluster-metrics_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-cluster-tools_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.api.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>

        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-testkit_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-protobuf_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>io.kamon</groupId>
            <artifactId>sigar-loader</artifactId>
            <version>1.6.6-rev002</version>
        </dependency>

        <dependency>
            <groupId>io.kamon</groupId>
            <artifactId>kamon-akka-remote_akka-2.4_2.11</artifactId>
            <version>0.6.1</version>
        </dependency>

        <dependency>
            <groupId>io.kamon</groupId>
            <artifactId>kamon-akka_2.11</artifactId>
            <version>0.6.1</version>
        </dependency>

        <!-- Check if this is needed -->
        <dependency>
            <groupId>io.kamon</groupId>
            <artifactId>kamon-core_2.11</artifactId>
            <version>0.6.1</version>
        </dependency>

        <dependency>
            <groupId>io.kamon</groupId>
            <artifactId>kamon-log-reporter_2.11</artifactId>
            <version>0.6.1</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
        </dependency>
        <dependency>
            <groupId>io.kamon</groupId>
            <artifactId>kamon-system-metrics_2.11</artifactId>
            <version>0.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.9</version>
        </dependency>

    </dependencies>

我的application.conf

akka {
  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
     serializers {
    java = "akka.serialization.JavaSerializer"
    }
    serialization-bindings {
    "java.lang.String" = java
    }
  }
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "127.0.0.1"
      port = 0
    }
  }

  cluster {
    seed-nodes = [
      "akka.tcp://ClusterSystem@127.0.0.1:2551",
      "akka.tcp://ClusterSystem@127.0.0.1:2552"]

    # auto downing is NOT safe for production deployments.
    # you may want to use it during development, read more about it in the docs.
    #
     auto-down-unreachable-after = 10s
  }
}
akka.cluster.metrics.enabled=true
akka.extensions=["akka.cluster.pubsub.DistributedPubSub","akka.cluster.client.ClusterClientReceptionist","kamon.akka.AkkaExtension"]

kamon {

  metric {

    # Time interval for collecting all metrics and send the snapshots to all subscribed actors.
    tick-interval = 10 seconds

    # Disables a big error message that will be typically logged if your application wasn't started
    # with the -javaagent:/path-to-aspectj-weaver.jar option. If you are only using KamonStandalone
    # it might be ok for you to turn this error off.
    disable-aspectj-weaver-missing-error = false

    # Specify if entities that do not match any include/exclude filter should be tracked.
    track-unmatched-entities = yes

    filters {
      akka-actor {
        includes = ["*/user/*"]
        excludes = [ "*/system/**", "*/user/IO-**", "*kamon*" ]
      }

      akka-router {
        includes = ["*/user/*"]
        excludes = []
      }

      akka-dispatcher {
        includes = ["*/user/*"]
        excludes = []
      }

      trace {
        includes = [ "**" ]
        excludes = [ ]
      }
    }

    modules {
    kamon-akka.auto-start = yes
    kamon-akka-remote.auto-start = yes
    kamon-log-reporter.auto-start = yes
    kamon-system-metrics.auto-start = yes 

    kamon-log-reporter {
      requires-aspectj = no
      auto-start = yes
      extensions = ["kamon.logreporter.LogReporter"]
    }
}
  }

  # Controls whether the AspectJ Weaver missing warning should be displayed if any Kamon module requiring AspectJ is
  # found in the classpath but the application is started without the AspectJ Weaver.
  show-aspectj-missing-warning = yes
  }

我开始申请如下:

java -jar -Djava.library.path=./lib/hyperic-sigar-1.6.4/sigar-bin/lib -javaagent:./lib/aspectjweaver-1.8.9.jar <jar>

启动我的应用程序时出现以下异常

2016-06-27 20:30:49 INFO  com.sample.Main:66 - Using Actor System ClusterSystem
[INFO] [06/27/2016 20:30:50.213] [main] [akka.remote.Remoting] Starting remoting
Uncaught error from thread [ClusterSystem-akka.remote.default-remote-dispatcher-7] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[ClusterSystem]
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    akka/util/ByteString.apply(I)Ljava/lang/Object; @5: areturn
  Reason:
    Type integer (current frame, stack[0]) is not assignable to reference type
  Current Frame:
    bci: @5
    flags: { }
    locals: { 'akka/util/ByteString', integer }
    stack: { integer }
  Bytecode:
    0x0000000: 2a1b b603 99b0                         

    at akka.util.ByteString$ByteString1C$.apply(ByteString.scala:106)
    at akka.remote.transport.AkkaPduProtobufCodec$.constructControlMessagePdu(AkkaPduCodec.scala:235)
    at akka.remote.transport.AkkaPduProtobufCodec$.<init>(AkkaPduCodec.scala:153)
    at akka.remote.transport.AkkaPduProtobufCodec$.<clinit>(AkkaPduCodec.scala:1)
    at akka.remote.EndpointManager$$anonfun$9.apply(Remoting.scala:775)
    at akka.remote.EndpointManager$$anonfun$9.apply(Remoting.scala:745)
    at scala.collection.TraversableLike$WithFilter$$anonfun$map$2.apply(TraversableLike.scala:683)
    at scala.collection.Iterator$class.foreach(Iterator.scala:893)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:682)
    at akka.remote.EndpointManager.akka$remote$EndpointManager$$listens(Remoting.scala:745)
    at akka.remote.EndpointManager$$anonfun$receive$2.applyOrElse(Remoting.scala:504)[ERROR] [06/27/2016 20:30:50.745] [ClusterSystem-akka.remote.default-remote-dispatcher-7] [akka.actor.ActorSystemImpl(ClusterSystem)] Uncaught error from thread [ClusterSystem-akka.remote.default-remote-dispatcher-7] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    akka/util/ByteString.apply(I)Ljava/lang/Object; @5: areturn
  Reason:
    Type integer (current frame, stack[0]) is not assignable to reference type
  Current Frame:
    bci: @5
    flags: { }
    locals: { 'akka/util/ByteString', integer }
    stack: { integer }
  Bytecode:
    0x0000000: 2a1b b603 99b0                         

    at akka.util.ByteString$ByteString1C$.apply(ByteString.scala:106)
    at akka.remote.transport.AkkaPduProtobufCodec$.constructControlMessagePdu(AkkaPduCodec.scala:235)
    at akka.remote.transport.AkkaPduProtobufCodec$.<init>(AkkaPduCodec.scala:153)
    at akka.remote.transport.AkkaPduProtobufCodec$.<clinit>(AkkaPduCodec.scala:1)
    at akka.remote.EndpointManager$$anonfun$9.apply(Remoting.scala:775)
    at akka.remote.EndpointManager$$anonfun$9.apply(Remoting.scala:745)
    at scala.collection.TraversableLike$WithFilter$$anonfun$map$2.apply(TraversableLike.scala:683)
    at scala.collection.Iterator$class.foreach(Iterator.scala:893)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:682)
    at akka.remote.EndpointManager.akka$remote$EndpointManager$$listens(Remoting.scala:745)
    at akka.remote.EndpointManager$$anonfun$receive$2.applyOrElse(Remoting.scala:504)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:482)
    at akka.remote.EndpointManager.aroundReceive(Remoting.scala:403)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    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)


    at akka.actor.Actor$class.aroundReceive(Actor.scala:482)
    at akka.remote.EndpointManager.aroundReceive(Remoting.scala:403)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    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)

如果我在运行应用程序时丢弃了aspectJweaver jar,它会正常启动但是,它不会打印任何actor指标。它只打印系统指标,如下所示

[INFO] [06/28/2016 13:07:38.302] [kamon-akka.actor.default-dispatcher-2] [akka://kamon/user/kamon-log-reporter] 
+--------------------------------------------------------------------------------------------------+
|                                                                                                  |
|    CPU (ALL)                                                                                     |
|                                                                                                  |
|    User (percentage)       System (percentage)    Wait (percentage)   Idle (percentage)          |
|       Min: 1                     Min: 0                 Min: 0             Min: 87               |
|       Avg: 4.0                   Avg: 0.0               Avg: 1.0           Avg: 92.0              |
|       Max: 9                     Max: 2                 Max: 8             Max: 97               |
|                                                                                                  |
|                                                                                                  |
+--------------------------------------------------------------------------------------------------+
[INFO] [06/28/2016 13:07:38.302] [kamon-akka.actor.default-dispatcher-2] [akka://kamon/user/kamon-log-reporter] 
+--------------------------------------------------------------------------------------------------+
|                                                                                                  |
|    Process-CPU                                                                                   |
|                                                                                                  |
|             User-Percentage                           Total-Percentage                           |
|                Min: 0                                    Min: 0                                  |
|                Avg: 1.0                                  Avg: 1.0                                |
|                Max: 3                                    Max: 3                                  |
|                                                                                                  |
+--------------------------------------------------------------------------------------------------+
[INFO] [06/28/2016 13:07:38.302] [kamon-akka.actor.default-dispatcher-2] [akka://kamon/user/kamon-log-reporter] 
+--------------------------------------------------------------------------------------------------+
|                                                                                                  |
|    Network (ALL)                                                                                 |
|                                                                                                  |
|     Rx-Bytes (KB)                Tx-Bytes (KB)              Rx-Errors            Tx-Errors       |
|      Min: 0                     Min: 0                    Total: 0             Total: 0         |
|      Avg: 305.0                Avg: 277.0                                                     |
|      Max: 1776                  Max: 1496                                                       |
|                                                                                                  |
+--------------------------------------------------------------------------------------------------+
[INFO] [06/28/2016 13:07:38.303] [kamon-akka.actor.default-dispatcher-2] [akka://kamon/user/kamon-log-reporter] 
+--------------------------------------------------------------------------------------------------+
|                                                                                                  |
|    Context-Switches                                                                              |
|                                                                                                  |
|        Global                Per-Process-Non-Voluntary            Per-Process-Voluntary          |
|    Min: 19660800                       Min: 3                             Min: 2                 |
|    Avg: 1.9778764E7                    Avg: 3.0                           Avg: 2.0               |
|    Max: 19791872                       Max: 3                             Max: 2                 |
|                                                                                                  |
+--------------------------------------------------------------------------------------------------+
[INFO] [06/28/2016 13:07:38.303] [kamon-akka.actor.default-dispatcher-2] [akka://kamon/user/kamon-log-reporter] No metrics reported

1 个答案:

答案 0 :(得分:0)

回答我自己的问题,

我对我的pom进行了以下修改

添加了依赖

<dependency>
    <groupId>io.kamon</groupId>
    <artifactId>kamon-autoweave_2.11</artifactId>
    <version>0.6.1</version>
</dependency>

删除了kamon-akka-remote-2.4_2.11 jar

将我的application.conf更改为

kamon {

  metric {

    # Time interval for collecting all metrics and send the snapshots to all subscribed actors.
    tick-interval = 60 seconds

    disable-aspectj-weaver-missing-error = false

    # Specify if entities that do not match any include/exclude filter should be tracked.
    track-unmatched-entities = yes

    filters {
      akka-actor {
        includes = ["**","ClusterSystem/user/**"]
        excludes = []
      }

      akka-router {
        includes = ["**","ClusterSystem/user/**"]
        excludes = []
      }

      akka-dispatcher {
        includes = ["**","ClusterSystem/user/**"]
        excludes = []
      }

      trace {
        includes = [ "**","ClusterSystem/user/**"]
        excludes = []
      }
    }
  }

  show-aspectj-missing-warning = no
 kamon-log-reporter {
      requires-aspectj = no
      auto-start = yes
    }

}

由于添加了autoweave jar,我们不需要在启动应用程序时提供-javaagent参数。