(neophyte question) I've just installed cassandra 3.5 (on linux, using the generic package). At present, it's a completely vanilla installation - I haven't modified the conf file and haven't created or added anything yet.
I can connect using cqlsh but not using the javax java driver (version 2.0.2). E.g. if I run
BasicConfigurator.configure();
Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
System.out.println("\nCluster name: " + cluster.getClusterName()+"\n");
Session session = cluster.connect();
the result is
0 [main] DEBUG com.datastax.driver.core.Cluster - Starting new cluster with contact points [/127.0.0.1:9042]
Cluster name: cluster1
112 [New I/O worker #1] DEBUG com.datastax.driver.core.Connection - Defuncting connection to /127.0.0.1:9042
com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Unexpected exception triggered (java.lang.IndexOutOfBoundsException: Not enough readable bytes - Need 4, maximum is 0)
at com.datastax.driver.core.Connection$Dispatcher.exceptionCaught(Connection.java:601)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)
...
The exception is being thrown by cluster.connect().
I suspect I've left something out. Any suggestions would be appreciated. Thanks.
datastax java driver 2.0.2 is not capable of connecting to cassandra 3.x+ clusters. Upgrading to 3.0.x (i.e. 3.0.2 which is the latest) should resolve this issue.
For future reference you can see what versions of C* are supported with driver versions on the DataStax drivers matrix page.
Related
I have created a cluster called test with three nodes in my machine using ccm (All the nodes are UP). I want to access the cluster using Java API.
However, I get the error below:
All host(s) tried for query failed (tried: /127.0.0.1:9042(com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces)
Cassandra version : 3.11.4
cassandra driver core : 2.1.9
Part of my code :
public static void main(String args[])
{
//creating Cluster object
Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
//Creating Session object
Session session = cluster.connect();
}
Anyway to resolve this?
Apparently schema_keyspaces isnt available in the specified cassandra version. I suggest to utilize the latest cassandra drivers , since that it is compatibility issue.
Version 2.1 of the Cassandra Java driver is not compatible with Apache Cassandra 3.11 (see the Compatibility Matrix).
You will need to upgrade to at least Java driver v3.0 to connect to a Cassandra 3.11 cluster. Cheers!
In our java application version 1 which is using cassandra 2.1
At startup we are executing query : "*SELECT * from system.schema_keyspaces;*" to get keyspace info (if this fails application wont start)
However new code we are getting the keypspace information from driver's cluster.metadata instance which is using cassandra 3.11
We are using DC aware RoundRobin load balancing policy of java
datastax driver.
Now consider a scenario with upgrade of 3 nodes : A,B and C, where A is upgraded (new application + Cassandra 3.11), upgrade on B is under process (Cassandra is down here) and C is not upgraded (old application + Cassandra 2.1). and your client application on C node restarts.
I am getting InvalidQueryException if the old query present on java client of C node gets executed on A (as client will send query in round robin way). if it fails there is no handling in old application. How can we resolve this issue ?
com.datastax.driver.core.exceptions.InvalidQueryException: un-configured table schema_keyspaces
One way i figured out that remove A's Ip from contact points of client application + peers table on C Cassandra node . Now Restart the client application. and then Cassandra to restore peers table entry.
Other way is keep restarting the client application on C until client application query actually hit the Cassandra 2.1 and successfully restarts. But that seems ugly to me.
In your application it's better to explicitly set protocol version to match Cassandra 2.1, instead of trying to rely on auto-negotiation features. Driver's documentation explicitly says about this.
According the compatibility matrix you need to explicitly set protocol version to V3, but this also depends on the driver version, so you may need to stuck to version 2.
Cluster cluster = Cluster.builder()
.addContactPoint("xxxx")
.withProtocolVersion(ProtocolVersion.V3)
.build();
After upgrade to 3.11 is done you can switch to protocol version 4.
I have tried connecting to a remote Cassandra from Windows 10 using the latest Simba-Datastax ODBC Driver (trial version). I was successful with Cassandra 2.1 (I connected to a Cassandra docker actually) but failed with Cassandra 3.0.15 and 3.11. I have installed the driver and I am able to see it in the Windows Data sources tool (64 bits), under the System DSN tab.
When I specify the host, port and keyspace of my Cassandra 3.0 docker (exactly the same values that work allright for me with the Cassandra 2.1 docker) and press the "Test..." button to launch the connectivity test, I am getting a strange error that "not even procol version 1 is available".
According to this web site, Simba says the driver is compatible with Cassandra 3.X. Could you think of any reason why this fails but 2.1 is successful? :-(
PS: I see other people complaining here but with a different error message (No hosts available for the control connection)
I fixed it! I think I was using a wrong version of the driver - I was using Datastax driver which apparently does not work for Cassandra 3.X. I have now downloaded the latest version of the ODBC driver from the Simba website (30-day trial version) and it is working :-)
The confusion came from the fact that I thought the Datastax driver and the Simba driver were the same as I read somewhere that "Simba and Datastax have partnered to develop a driver...".
Thank you very much Aaron anyway.
Is the spring-data-cassandra version 1.4.2 compatible with cassandra version 3.7? I get the following error when I try to connect:
Error creating bean with name 'cassandraSession': Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError:
io/netty/util/concurrent/EventExecutor
No, Spring Data Cassandra 1.4.x is based on the 2.x DataStax's Cassandra driver.
However, in Spring Data Cassandra 1.5 (Ingalls) release series (currently at 1.5 M1), we have upgraded the DataStax Cassandra driver to 3.0.3. We have also removed support for the DataStax DSE (DataStax Enterprise) driver since it is unnecessary for SD Cassandra functionality.
There were significant changes in the 3.0 version of DataStax's Java driver API requiring us to introduce 3.0 support in 1.5. We would not be able to back port these changes without adversely affecting 1.4 users.
You can find out more by reading our SD Ingalls M1 release announcement.
Also, you can follow the development of SD Cassandra 1.5 on the Wiki.
Feedback is always welcomed, either with PRs or through JIRA.
If I create a new project like this .
cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
this code works.
But if I take all the jars from this project and migrate the jars to my own project .the code above doesn't work and it says:
13/07/01 16:27:16 ERROR core.Connection: [/127.0.0.1-1] No handler set for stream 1 (this is a bug, either of this driver or of Cassandra, you should report it)
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])
What version of Cassandra are you running? Have you enabled the native protocol in your cassandra.yaml?
In Cassandra 1.2.0-1.2.4 the native protocol was disabled by default, but in 1.2.5+ it's on by default.
See https://github.com/apache/cassandra/blob/cassandra-1.2.5/conf/cassandra.yaml#L335
That's the most common reason I've seen for not being able to connect with the driver.