主线程java.lang.NoClassDefFoundError中的异常 [英] Exception in main thread java.lang.NoClassDefFoundError

查看:980
本文介绍了主线程java.lang.NoClassDefFoundError中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取错误线程main中的异常java.lang.NoClassDefFoundError:com / google / common / util / concurrent / FutureCallback,而运行下面的代码。建议哪些JAR文件丢失。我从Eclipse IDE执行

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:


  • 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

  • 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

此链接: http://www.datastax.com/documentation /developer/java-driver/2.1/java-driver/reference/settingUpJavaProgEnv_r.html

否则,您可以使用Maven,如果您使用IDE蚀。有关依赖性示例,请参阅以下链接: http:// www .datastax.com / documentation / developer / java-driver / 2.1 / common / drivers / introduction / driverDependencies_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

请注意,您还需要确保 start_native_transport:true 在您的cassandra.yaml配置文件中也概述了上面的链接。

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.

要安装Maven into Eclipse我建议使用这个优秀的分步: Maven in Eclipse:一步一步安装

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

希望这有助于!

这篇关于主线程java.lang.NoClassDefFoundError中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆