Achilles: Achilles Junit: NoClassDefFoundError: com/codahale/metrics/JmxReporter

Spring Boot 2.1, Cassandra driver 3.6.0, achilles-junit 6.0.0

I use achilles-junit as embedded Cassandra in spring boot test cases. But after upgrade from Spring boot 2.0 to 2.1 the tests fail with an exception:

java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
	at com.datastax.driver.core.Metrics.<init>(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 com.datastax.driver.core.Cluster.connect(Cluster.java:305)
	at info.archinnov.achilles.embedded.AchillesInitializer.initializeFromParameters(AchillesInitializer.java:62)
	at info.archinnov.achilles.embedded.CassandraEmbeddedServer.<init>(CassandraEmbeddedServer.java:64)
	at info.archinnov.achilles.embedded.CassandraEmbeddedServerBuilder.buildServer(CassandraEmbeddedServerBuilder.java:535)
	at info.archinnov.achilles.junit.AchillesTestResource.buildServer(AchillesTestResource.java:141)
	at info.archinnov.achilles.junit.AchillesTestResource.<init>(AchillesTestResource.java:118)
	at info.archinnov.achilles.junit.AchillesTestResourceBuilder.build(AchillesTestResourceBuilder.java:216)
	at com.platincoin.gidra.oauth.server.CassandraEmbeddedIntegrationTest.embeddedCassandra(CassandraEmbeddedIntegrationTest.java:86)
	at com.platincoin.gidra.oauth.server.CassandraEmbeddedIntegrationTest.<init>(CassandraEmbeddedIntegrationTest.java:46)
	at com.platincoin.gidra.oauth.server.OAtuh2TokenReceivingTest.<init>(OAtuh2TokenReceivingTest.java:20)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:226)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

The application starts without any errors. Library metrics-core is exist in classpath (v.4.0.3).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (10 by maintainers)

Most upvoted comments

Achilles 6.0.1 released, will be available in a few hours on Maven Central

That’s a shame, but thanks for helping walk through the issue…

For now our workaround is downgrading dropwizard metrics through:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>achilles-issue-353</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <dropwizard-metrics.version>3.2.6</dropwizard-metrics.version>
    </properties>

Note that this, for now, seems to only way of using Spring Boot 2.1 that I could find, so it might be of use for others that stumble upon this issue.

hi @doanduyhai thanks, but doesn’t resolve the issue. I’ve created a sample project here: https://github.com/timtebeek/achilles-issue-353 Which shows the issue here: https://travis-ci.org/timtebeek/achilles-issue-353/builds/483284041 Adding the suggested exclusion still triggers the issue, as te shaded cassandra-driver-core:3.5.0 still tries to acess com.codahale.metrics.JmxReporter which in 4.x has been moved to com.codahale.metrics.jmx.JmxReporter.

Hope that helps clear things up. The problem appears to lie in the shaded cassandra driver, but excluding it leads to other problems. Could you see about upgrading to the 3.6.0 driver?