2

Getting error Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/util/concurrent/FutureCallback, while running below code. Pls advise which Jar file am missing. I am executing from Eclipse IDE

package Datastax;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.Session;


public class DataStaxPOC {
   private Cluster cluster;

   public void connect(String node) {

       cluster = Cluster.builder().addContactPoint(node).build();

      Metadata metadata = cluster.getMetadata();

      System.out.printf("Connected to cluster: %s\n", metadata.getClusterName());

      for ( Host host : metadata.getAllHosts() ) {
         System.out.printf("Datatacenter: %s; Host: %s; Rack: %s\n",host.getDatacenter(), host.getAddress(), host.getRack());
      }
   }

   public void close() {
      cluster.shutdown();
   }

   public static void main(String[] args) {
      DataStaxPOC client = new DataStaxPOC();
      client.connect("127.0.0.1");
      client.close();
   }
}

3 Answers 3

9

to setup your environment, you'll need the following resources:

  • cassandra-driver-core-2.1.0.jar
  • netty-3.9.0-Final.jar
  • guava-16.0.1.jar
  • metrics-core-3.0.2.jar
  • slf4j-api-1.7.5.jar

(as outlined in this link: http://www.datastax.com/documentation/developer/java-driver/2.1/java-driver/reference/settingUpJavaProgEnv_r.html)

Otherwise you could use Maven if you are using an IDE like Eclipse. See the following link for a dependancy example: http://www.datastax.com/documentation/developer/java-driver/2.1/common/drivers/introduction/driverDependencies_r.html

Note you also need to ensure that the the start_native_transport: true is in your cassandra.yaml configuration file also outlined in the above link.

To install Maven into Eclipse I'd recommend using this excellent step-by-step: Maven in Eclipse: step by step installation

Hope this helps!

2

You need to have cassandra-driver-core-2.0.1.jar , netty-3.9.0-Final.jar , guava-16.0.1.jar , metrics-core-3.0.2.jar , and slf4j-api-1.7.5.jar on the classpath.

1

i too faced the same issue but after adding the following jars the issue get resolved, 1. bsh-2.0b4.jar 2. guava-16.0.1.jar 3. jcommander-1.27.jar 4. log4j-1.2.17.jar 5. lz4-1.2.0.jar 6. metrics-core-3.0.2.jar 7. netty-3.9.0.Final 8. slf4j-api-1.7.5.jar 9. slf4j-log4j12-1.7.6.jar 10. snappy-java-1.0.5.jar.

hope this will help you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.