incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dong.yajun" <dongt...@gmail.com>
Subject Could not connect to cassandra 1.0.9
Date Thu, 21 Jun 2012 02:10:00 GMT
Hi list

I'd like to connect to remote Cassandra using Java client, the following
code I use, but ImcompatibleClassChangeError was occured, the source that
was just dependent on the following jars:

apache-cassandra-1.0.9.jar, apache-cassandra-clientutil-1.0.9.jar,
apache-cassandra-thrift-1.0.9.jar

and the code:

import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestClient {
 private static final Logger logger =
LoggerFactory.getLogger(TestClient.class);

private static Cassandra.Iface createConnection()
throws TTransportException {
if (System.getProperty("cassandra.host") == null
|| System.getProperty("cassandra.port") == null) {
logger.warn("cassandra.host or cassandra.port is not defined, using
default");
}
return createConnection("echadoop01", 9160, true);
}

private static Cassandra.Client createConnection(String host, Integer port,
boolean framed) throws TTransportException {
TSocket socket = new TSocket(host, port);
TTransport trans = framed ? new TFramedTransport(socket) : socket;
trans.open();
TProtocol protocol = new TBinaryProtocol(trans);

return new Cassandra.Client(protocol);
}

public static void main(String args[]) throws TTransportException {
Cassandra.Iface client = createConnection();
}
}

and the exception:

Exception in thread "main" java.lang.IncompatibleClassChangeError:
Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)d
at com.newegg.cassandra.TestClient.createConnection(TestClient.java:33)
at com.newegg.cassandra.TestClient.createConnection(TestClient.java:23)
at com.newegg.cassandra.TestClient.main(TestClient.java:37)

Does anyone have this kind of problem before? the above code could running
with Cassandra1.0.7.  Thank you in advance.


-- 
Best.

*Ric Dong *

Mime
View raw message