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();
}
}
to setup your environment, you'll need the following resources:
(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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With