Home > other >  Does ScyllaDB Support Latest Version of Metrics?
Does ScyllaDB Support Latest Version of Metrics?

Time:05-16

When I launch ScyllaDB for the first time:

Cluster cluster = Cluster.builder().addContactPoints("xx.xxx.xx.xxx").build();
Session session = cluster.connect("my_scylladb_cluster");

System.out.println(session.isClosed());

I get the following error:

===== Using optimized driver!!! =====
Exception in thread "main" java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
    at com.datastax.driver.core.Metrics.<init>(Metrics.java:156)
    at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1773)
    at com.datastax.driver.core.Cluster.init(Cluster.java:228)
    at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:401)
    at com.datastax.driver.core.Cluster.connect(Cluster.java:352)
    at scylladbX.ScyllaDBXMain.main(ScyllaDBMain.java:12)
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

In my Maven POM file I'm using the latest version of Metrics:

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

    <!-- https://mvnrepository.com/artifact/io.dropwizard.metrics/metrics-graphite -->
    <dependency>
        <groupId>io.dropwizard.metrics</groupId>
        <artifactId>metrics-graphite</artifactId>
        <version>4.2.9</version>
    </dependency>

I noticed that if I downgrade to a much earlier version of Metrics, the problem goes away:

    <!-- https://mvnrepository.com/artifact/com.codahale.metrics/metrics-core -->
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-core</artifactId>
        <version>3.0.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.codahale.metrics/metrics-graphite -->
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-graphite</artifactId>
        <version>3.0.0</version>
    </dependency>

Does ScyllaDB not support the latest version of Metrics? What is the latest version supported?

Thanks

CodePudding user response:

The DataStax Java Driver documentation here has a section about the problem you saw:

While the driver depends on Metrics 3.2.x, it also works with Metrics 4, with some caveats. In Metrics 4, JMX reporting was moved to a separate module, metrics-jmx. Because of this you are likely to encounter the following exception at runtime when initializing a Cluster:

Exception in thread "main" java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
   at com.datastax.driver.core.Metrics.<init>(Metrics.java:103)
   at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1402)
   at com.datastax.driver.core.Cluster.init(Cluster.java:159)
   at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:330)
   at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:305)
   at com.datastax.durationtest.core.DurationTest.createSessions(DurationTest.java:360)
       ....
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
   ... 8 more

That document also has suggestions what to do in this case.

In any case, this problem has nothing to do with Scylla (the backend server you want to connect to) - and is just a problem with the Java client ("driver") you are using.

  • Related