Error > Missing com/codahale/metrics/JmxReporter class


(rahat) #1

I am getting some errors while trying to run following example:
https://developer.lightbend.com/guides/akka-distributed-workers-scala/

Error is saying - java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
And I can see, JmxReporter class is actually missing inside metrics-core-4.0.3.jar
but Metrics class of cassandra driver ( cassandra-driver-core-3.6.0.jar) is calling it.
This maybe related to cassandra plugins.

any tips how to fix this issue ?

Versions:

<java.version>1.8</java.version>
<scala.version>2.12.7</scala.version>
<akka.version>2.5.19</akka.version>
0.91

cassandra Plugins:

com.typesafe.akka
akka-persistence-cassandra_2.12
{cassandraPluginVersion}</version> </dependency> <dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-persistence-cassandra-launcher_2.12</artifactId> <version>{cassandraPluginVersion}

Error:

20:12:28.261 [ClusterSystem-akka.actor.default-dispatcher-2] INFO a.c.Cluster(akka://ClusterSystem) - Cluster Node [akka.tcp://ClusterSystem@127.0.0.1:5002] - Welcome from [akka.tcp://ClusterSystem@127.0.0.1:2551]
Uncaught error from thread [Uncaught error from thread [ClusterSystem-cassandra-plugin-default-dispatcher-25]: com/codahale/metrics/JmxReporter, shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[ClusterSystem]
ClusterSystem-cassandra-plugin-default-dispatcher-26]: com/codahale/metrics/JmxReporter, shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[ClusterSystem]
java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
at com.datastax.driver.core.Metrics.(Metrics.java:146)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1501)
at com.datastax.driver.core.Cluster.init(Cluster.java:208)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:376)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:355)
at akka.persistence.cassandra.ConfigSessionProvider.$anonfun$connect$1(ConfigSessionProvider.scala:49)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:303)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)


(rahat) #2

Update
I had raise an issue below:
https://datastax-oss.atlassian.net/projects/JAVA/issues/JAVA-2079?filter=allissues

Response for the issue is below:
we are trying to maintain compatibility with Metrics 3.x so we don’t break existing users. We do support Metrics 4.x, however for it to work you will need to make some adjustments, covered in Metrics 4 Compatibility.

The next major version of the java driver (4.0) will use metrics 4.

Which means, need to follow below recommendation:

https://docs.datastax.com/en/developer/java-driver/3.6/manual/metrics/#metrics-4-compatibility

But I am just using,
akka.persistence.cassandra.testkit.CassandraLauncher

is that mean, CassandraLauncher need to be updated ?


(Tim Moore) #3

@rahat the example you pointed to is an sbt project, but it looks from your post like you are running a Maven project. Is that right? Did you author the pom.xml yourself? Could you post a link to that?

The example runs correctly when I follow the instructions on the page, and it’s using metrics-core-3.2.2.jar. I think the simplest solution will be to try to get your project closer to the example, so try to find out why it’s using metrics-core-4.0.3.jar. You could use the mvn dependency:tree command to see what is bringing in the newer version.

Have you added Cinnamon to your project? That does depend on Metrics 4 by default. You can switch it back go Metrics 3 by following the instructions at https://developer.lightbend.com/docs/cinnamon/current/project/migration-2.10.html


(rahat) #4

Hi Tim Moore,

Thanks a lot for your response. After reading your response, I just added metrics-core-3.2.2.jar dependency manually to see what happens, and issue disappeared and demo app started working !!

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.2.2</version>
</dependency>

However, I didn’t add any cinnamon dependency, but I created the initial project from spring initializr https://start.spring.io/, and spring-boot-maven-plugin is still there, not sure if that was causing the issue!