这是我当前的错误:
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1 (com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered (java.lang.NoClassDefFoundError: Could not initialize class com.datastax.driver.core.Codec)))
com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:186)
com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:81)
com.datastax.driver.core.Cluster$Manager.init(Cluster.java:773)
com.datastax.driver.core.Cluster$Manager.access$100(Cluster.java:706)
com.datastax.driver.core.Cluster.<init>(Cluster.java:79)
com.datastax.driver.core.Cluster.<init>(Cluster.java:66)
com.datastax.driver.core.Cluster$Builder.build(Cluster.java:687)
com.t2.claims.persistence.CassandraClient.getOrCreateCluster(CassandraClient.java:12)
com.t2.claims.persistence.CassandraClient.getOrCreateSession(CassandraClient.java:18)
com.t2.claims.dao.AlertDaoImpl.findAll(AlertDaoImpl.java:25)
com.t2.claims.controllers.AlertIndexController.doAfterCompose(AlertIndexController.java:36)
org.zkoss.zk.ui.impl.UiEngineImpl.doAfterCompose(UiEngineImpl.java:529)
....
我觉得我正在导入我需要的所有可用的人工制品(以及许多我不想试图克服这个问题)。
我只是无法理解为什么这不起作用?
这是我pom.xml
的完整性:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.t2.claims</groupId>
<artifactId>T2ClaimsPortal</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>T2ClaimsPortal</name>
<properties>
<spring.version>3.2.0.RELEASE</spring.version>
<zk.version>6.0.2.1</zk.version>
<commons-lang.version>2.4</commons-lang.version>
<commons-fileupload.version>1.2.1</commons-fileupload.version>
<commons-io.version>1.3.1</commons-io.version>
<commons-logging.version>1.1.1</commons-logging.version>
</properties>
<repositories>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
<repository>
<id>ZK EE</id>
<url>https://maven.zkoss.org/repo/zk/ee/</url>
</repository>
</repositories>
<dependencies>
<!-- Hector -->
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-core</artifactId>
<version>0.8.0-2</version>
</dependency>
<!-- cassandra -->
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>1.0.4</version>
</dependency>
<!-- cassandra dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.1</version>
</dependency>
<!-- spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<!-- ZK -->
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkplus</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-core</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.zkoss.theme</groupId>
<artifactId>sapphire</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zul</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.common</groupId>
<artifactId>zcommon</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zk</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.common</groupId>
<artifactId>zweb</artifactId>
<version>${zk.version}</version>
</dependency>
<!-- ZK dependencies -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- javax servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- ***************************************************************************** -->
<!-- ************************** JACKSON ****************************************** -->
<!-- ***************************************************************************** -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
<version>3.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>2.0</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.hectorclient</groupId>
<artifactId>hector-core</artifactId>
<version>1.1-4</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.hectorclient</groupId>
<artifactId>hector-object-mapper</artifactId>
<version>3.1-09</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.9.Final</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>2.2.0-incubating</version>
</dependency>
</dependencies>
<build>
<finalName>T2ClaimsPortal</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
有人可以让我理解为什么我会得到这个例外吗?我有一个本地运行的cassandra客户端。 (版本1.2.11)。
答案 0 :(得分:4)
这不是你的pom文件的问题。您的客户端(DataStax Java驱动程序)无法访问您的cassandra数据库。可能是因为几个原因:
答案 1 :(得分:1)
我在虚拟机上安装了Cassandra Server,但我无法远程访问它。我获得了例外:
com.datastax.driver.core.exceptions.NoHostAvailableException:
All host(s) tried for query failed (tried: /192.168.1.76:9042 (com.datastax.driver.core.TransportException: [/192.168.1.76:9042] Cannot connect))
首先,我确认无法通过telnet访问端口9042。
我解决了在Cassandra Server上修改cassandra.yaml配置文件的问题,
rpc_address = 0.0.0.0
broadcast_rpc_address = 1.2.3.4
那是因为
rpc_address(或rpc_interface)用于客户端连接, listen_address属性用于节点间通信。
答案 2 :(得分:0)
您的cassandara服务器似乎没有收听您的请求。 试试telnet 127.0.0.1 9160
如果你得到这个 telnet:无法连接到远程主机:连接被拒绝 对于jdbc库使用DataStax驱动程序,它更成熟,无bug
<dependency>
<groupId>org.apache-extras.cassandra-jdbc</groupId>
<artifactId>cassandra-jdbc</artifactId>
<version>1.2.5</version>
</dependency>
然后重启你的cassandara
答案 3 :(得分:0)
问题太相似了:我的Spring应用程序因NoHostAvailable而失败,我可以通过在配置文件cassandra.yaml中设置rpc_port和native_transport_port来匹配它,以匹配用于连接到cassandra的eaxct IP地址(即Cluster。 builder()。addContactPoints(...这里的IP地址......)),但后来它是cqlsh,因为主机没有监听而不再启动...直到我意识到听众(rpc或本地传输)正在监听在127.0.0.1上,否则是主机的真正的IP 10.0.0.5,这在这个实现中有点不同!所以我通过调整cqlsh脚本以使用10.0.0.5并获得解析为127.0.0.1而不是10.0.0.5的localhost名称的rif来解决它...这不符合最初的IP网络原则来建立一个终端应用程序做出这样的改变。