1
votes

I am trying to connect DSE 5.0 server on ubuntu (with graph enable) with my java code but got this error

Exception in thread "main" java.lang.NoClassDefFoundError: io/netty/handler/timeout/IdleStateHandler
    at com.datastax.driver.core.Connection$Initializer.<init>(Connection.java:1409)
    at com.datastax.driver.core.Connection.initAsync(Connection.java:144)
    at com.datastax.driver.core.Connection$Factory.open(Connection.java:796)
    at com.datastax.driver.core.ControlConnection.tryConnect(ControlConnection.java:253)
    at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:201)
    at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
    at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1473)
    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.driver.core.Cluster.connect(Cluster.java:247)
    at com.datastax.driver.core.DelegatingCluster.connect(DelegatingCluster.java:71)
    at com.datastax.driver.dse.DseCluster.connect(DseCluster.java:351)

As the error says the netty library is probably missing.

I added netty-all in my pom.xml but then also got same error.

Pom.xml

<dependency>
    <groupId>com.datastax.cassandra</groupId>
    <artifactId>dse-driver</artifactId>
    <version>1.1.1-beta1</version>
</dependency>
<dependency>
    <groupId>com.datastax.cassandra</groupId>
    <artifactId>dse-driver</artifactId>
    <version>1.1.1-beta1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.6.Final</version>
</dependency>

Thanks for help..!

1
Is the class in question contained in any of those three artefacts? - hotzst
I think netty-all contain all netty artifacts - Prakash Pandey

1 Answers

1
votes

The java driver is built and tested against Netty 4.0 (see JAVA-1241 for 4.1 support). It's possible that there is some incompatibility that prevents this from working (although I see IdleStateHandler in that path in Netty 4.1).

If you need to use a different version of Netty in your project, you can consider using the shaded classifier of the driver which includes its own bundled version of netty under its own package structure. Since you are using the dse driver you'll also need to exclude the core driver from its dependency definition (this will be less complicated in the future):

    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>3.1.3</version>
        <classifier>shaded</classifier>
        <!-- Because the shaded JAR uses the original POM, you still need
             to exclude this dependency explicitly: -->
        <exclusions>
            <exclusion>
                <groupId>io.netty</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>dse-driver</artifactId>
        <version>1.1.1-beta1</version>
        <exclusions>
            <exclusion>
                <groupId>com.datastax.cassandra</groupId>
                <artifactId>cassandra-driver-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>