4

I am trying to connect to Cassandra DB from Wso2 ESB & wso2 DSS, in both the approaches getting the same error.

1) Approach 1: Connecting to Cassandra from WSO2 ESB

We are trying to connect Cassandra DB 3.0.3 from Wso2 ESB 4.9

Below are the jars copied to components/lib folder.

(jar listing) In master-datasource.xml below is the configuration added.

<datasource>
        <name>CassandraDB</name>
        <description>The datasource used for cassandra</description>
                                <jndiConfig>
            <name>cassandraWSO2DB</name>
        </jndiConfig>
            <definition type="RDBMS">
            <configuration>
                <url>jdbc:cassandra://127.0.0.1:9042/sample</url>(tried with port 9160)
                <username>cassandra</username>
                <password>cassandra</password>
                <driverClassName>org.apache.cassandra.cql.jdbc.CassandraDriver</driverClassName>
                <maxActive>50</maxActive>
                <maxWait>60000</maxWait>
                <testOnBorrow>true</testOnBorrow>
                <validationQuery>SELECT COUNT(*) from sample.users</validationQuery>
                <validationInterval>30000</validationInterval>
                <defaultAutoCommit>true</defaultAutoCommit>
            </configuration>
        </definition>
    </datasource>

2) Approach 2: Connecting to Cassandra from WSO2 DSS

We are trying to connect Cassandra DB from Wso2 DSS 3.5.0 Below are the jars copied to components/lib folder.

Created the Data service and added the data source below is the configuration for the same:

<config enableOData="false" id="CassandraSampleId">
  <property name="url">jdbc:cassandra://127.0.0.1:9042/sample</property>
  <property name="driverClassName">org.apache.cassandra.cql.jdbc.CassandraDriver</property>

 <query id="SampleQuery" useConfig="CassandraSampleId">
  <expression>select * from users</expression>

In the above configuration “sample” is the keyspace created in Cassandra. In the both the cases i.e. 1 & [2] facing the same below error. Can you please suggest to resolve the issue.

java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!

    at org.wso2.carbon.dataservices.core.description.config.RDBMSConfig.<init>(RDBMSConfig.java:45)
    at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.getRDBMSConfig(ConfigFactory.java:92)
    at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.createConfig(ConfigFactory.java:60)
    at org.wso2.carbon.dataservices.core.DataServiceFactory.createDataService(DataServiceFactory.java:150)
    at org.wso2.carbon.dataservices.core.DBDeployer.createDBService(DBDeployer.java:785)
    at org.wso2.carbon.dataservices.core.DBDeployer.processService(DBDeployer.java:1139)
    at org.wso2.carbon.dataservices.core.DBDeployer.deploy(DBDeployer.java:195)
    ... 8 more
Caused by: java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
        at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:159)
        at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92)
        at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:278)
        at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
        at org.wso2.carbon.dataservices.core.description.config.SQLConfig.createConnection(SQLConfig.java:187)
        at org.wso2.carbon.dataservices.core.description.config.SQLConfig.createConnection(SQLConfig.java:173)
        at org.wso2.carbon.dataservices.core.description.config.SQLConfig.initSQLDataSource(SQLConfig.java:151)
        at org.wso2.carbon.dataservices.core.description.config.RDBMSConfig.<init>(RDBMSConfig.java:43)
        ... 14 more
Caused by: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
        at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:133)
        at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101)
        at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
        at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
        at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
        at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
        at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
        at org.apache.cassandra.thrift.Cassandra$Client.recv_describe_cluster_name(Cassandra.java:1101)
        at org.apache.cassandra.thrift.Cassandra$Client.describe_cluster_name(Cassandra.java:1089)
        at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:130)
Community
  • 1
  • 1

1 Answers1

1
<query id="SampleQuery" useConfig="CassandraSampleId">
  <expression>select * from users</expression>

<validationQuery>SELECT COUNT(*) from sample.users</validationQuery>

First thing I noticed...unbound queries are not a good idea to do in Cassandra. You should always query with a partition key. This won't fix your problem, but you definitely do not want to do that in production with millions of rows.

We are trying to connect Cassandra DB 3.0.3 from Wso2 ESB 4.9

       <definition type="RDBMS">
        <configuration>
            <url>jdbc:cassandra://127.0.0.1:9042/sample</url>(tried with port 9160)

org.apache.thrift.transport.TTransportException: 

Ok, a couple of things I noticed here. I've never used WSO2 (actually, I have no idea what it is) but it looks like it's making a couple of (bad) assumptions here.

  • I don't know what your options for "type" are, but Cassandra is definitely not a RDBMS.
  • I see you're using JDBC. There are MANY drivers out there that interact with Cassandra from Java. JDBC was originally designed for relational databases, and augmented to be used with Cassandra. You will have the highest chance for success by using the DataStax Java Driver, especially if you are running Cassandra 3.x.
  • I see it throwing a thrift.transport.TTransportException. Cassandra 3.0.3 installs with the thrift (9160) protocol disabled by default. Changing the port to 9042 isn't enough...you need to be using the native binary protocol for that to work.

The first thing to try, is to re-enable Thrift inside your Cassandra node. Inside your cassandra.yaml, find the start_rpc property, and set it to true:

start_rpc: true

At the very least, that will get Thrift running on 9160, and you'll be ready to try connecting again. However, I don't know if JDBC will even work with Cassandra 3.x. And if it does, you certainly won't get all of the available features.

The biggest problem I see here, is that you are trying to use a new version of Cassandra with technologies that it really wasn't designed to interact with. But try starting Thrift in Cassandra, and see if that helps. If anything, it should get you to the next problem.

Aaron
  • 55,518
  • 11
  • 116
  • 132
  • @kishoreNagula Did anything I suggested here help? Were you able to get this working? – Aaron Mar 29 '16 at 00:40
  • Hi Aaron, Thanks for looking into issue. tried with start_rpc: true but still same error. Used different version of cassandra drivers too. No luck. – kishore Nagula Apr 01 '16 at 04:23