14 Replies Latest reply on Apr 18, 2018 10:32 AM by Wolfgang Mayer

    Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0

    ANKIT LOHCHAB Newbie

      I am not able to import from teiid connection with cassandra3.x datasource and get the following error:

      2018-04-10 05:58:59,139 WARN  [org.teiid.RUNTIME] (Worker11_async-teiid-threads12)  TEIID50036 VDB importVDB.1 model "importVDBSrcModel" metadata failed to load. Reason:TEIID31178 Could not obtain connection for schema importVDBSrcModel, but one is required for metadata load. : org.teiid.translator.TranslatorException: TEIID31178 Could not obtain connection for schema importVDBSrcModel, but one is required for metadata load.

      at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:72)

      at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:58)

      at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:51)

      at org.teiid.jboss.VDBService$6.run(VDBService.java:337)

      at org.teiid.jboss.VDBService$7.run(VDBService.java:388)

      at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:280)

      at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:115)

      at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:206)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)

      at java.lang.Thread.run(Thread.java:811)

      Caused by: java.lang.ClassCastException: org.teiid.resource.spi.WrappedConnectionFactory incompatible with javax.sql.DataSource

      at org.teiid.translator.jdbc.JDBCExecutionFactory.getConnection(JDBCExecutionFactory.java:65)

      at org.teiid.translator.ExecutionFactory.getConnection(ExecutionFactory.java:201)

      at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:68)

      ... 10 more

       

       

       

      i am able to add cassandra driver to wildfly using the following in standalone.xml  file :-

       

       

      <driver name="cassandra" module="org.apache.hadoop.cassandra">

                              <driver-class>org.apache.cassandra.cql.jdbc.CassandraDriver</driver-class>

                              <xa-datasource-class>org.apache.cassandra.cql.jdbc.CassandraDataSource</xa-datasource-class>

                          </driver>

       

      cassandra module.xml looks like :-

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.0" name="org.apache.hadoop.cassandra">

          <resources>

              <resource-root path="cassandra-driver-core-3.4.0.jar" />

              <resource-root path="cassandra-jdbc-1.2.5.jar" />

              <resource-root path="cassandra-all-3.11.1.jar" />

              <resource-root path="slf4j-jdk14-1.7.24.jar" />

              <resource-root path="cassandra-jdbc-wrapper-3.1.0.jar" />

                </resources>

          <dependencies>

              <module name="javax.api"/>

              <module name="javax.resource.api"/>

              <module name="javax.transaction.api"/>

              <module name="org.slf4j"/>

      <module name="sun.jdk" export="true" >

         <imports>

                <include path="sun/misc/Unsafe" />

             </imports>

          </dependencies>

      </module>

        • 1. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
          Anup Dey Expert

          The issue is being caused because there are multiple instance of javax.sql.DataSource available in your classpath. As the issue is with the DataSource class, you should be able to get a connection via connecting directly to the DB.

           

          I could see that you are getting ClassCastException. ClassCastException exception could occur in your scenario if class  org.teiid.resource.spi.WrappedConnectionFactory  does not implement javax.sql.DataSource. However it does implement javax.sql.DataSource

           

          The other possibility is that even though org.teiid.resource.spi.WrappedConnectionFactory implements javax.sql.DataSource, ClassCastException could be thrown if both the classes are loaded from different classloaders. This could happen if you have packaged the DB driver class with your application. I would suggest you to provide all the driver libraries class inside the directory org/apache/hadoop/cassandra instead of your application.

           

          Remove this line: "<xa-datasource-class>org.apache.cassandra.cql.jdbc.CassandraDataSource</xa-datasource-class>" from driver section.. Keep only "<driver-class>org.apache.cassandra.cql.jdbc.CassandraDriver</driver-class>"

          • 2. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
            ANKIT LOHCHAB Newbie

            Thanks Anup!

             

            Still  having problem  in connecting my cassandraDB to wildfly. I am using Cassandra 3.0.9

            When I start the wildfly server, it will give me an error like this:

            16:59:50,473 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 37)  WFLYCTL0013: Operation ("add") failed - address: ([

                ("subsystem" => "datasources"),

                ("jdbc-driver" => "cassandra")

            ]) - failure description: "WFLYJCA0034: Unable to instantiate driver class \"org.apache.cassandra.cql.jdbc.CassandraDriver\".

             

            At location teiid-10.2.0\modules\system\layers\dv\org\apache\hadoop\cassandra\main , module.xml files looks like:

             

            <?xml version="1.0" encoding="UTF-8"?>

            <module xmlns="urn:jboss:module:1.0" name="org.apache.hadoop.cassandra">

            <resources>

                <resource-root path="cassandra-jdbc-wrapper-3.1.0.jar"/>

                <resource-root path="slf4j-jdk14-1.7.24.jar"/>

            </resources>

            <dependencies>

                <module name="javax.api"/>

            <module name="javax.transaction.api"/>

                <module name="sun.jdk" export="true" >

                   <imports>

                      <include path="sun/misc/Unsafe" />

                   </imports>

                </module>

            </dependencies>

            </module>

             

             

            cassandra driver is added as in standalone.xml:

             

            <driver name="cassandra" module="org.apache.hadoop.cassandra">

                  <driver-class>org.apache.cassandra.cql.jdbc.CassandraDriver</driver-class>

                </driver>

             

            Kindly provide any suggestion to solve this issue and to connect to cassandrad db.

             

            Thanks!

            • 3. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
              Wolfgang Mayer Master

              The driver path is org.apache.cassandra2.cql.jdbc.CassandraDriver

              • 4. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                ANKIT LOHCHAB Newbie

                When the driver path is org.apache.cassandra2.cql.jdbc.CassandraDriver it gives the following error:

                 

                ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 37)  WFLYCTL0013: Operation ("add") failed - address: ([

                    ("subsystem" => "datasources"),

                    ("jdbc-driver" => "cassandra")

                ]) - failure description: "WFLYJCA0041: Failed to load module for driver [org.apache.hadoop.cassandra]"

                • 5. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                  Wolfgang Mayer Master

                  It looks like your module is not found. It should be placed directly under $JBOSS_HOME/modules (eg $JBOSS_HOME/modules/org/cassandra/main/).

                  • 6. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                    ANKIT LOHCHAB Newbie

                    I do the following changes in module.xml :

                     

                    <?xml version="1.0" encoding="UTF-8"?>

                    <module xmlns="urn:jboss:module:1.0" name="org.apache.hadoop.cassandra">

                    <resources>

                    <resource-root path="cassandra-driver-core-3.4.0.jar" />

                                     <resource-root path="cassandra-jdbc-1.2.5.jar" />

                                    <resource-root path="cassandra-all-3.4.jar" />               

                    <resource-root path="cassandra-thrift-3.11.2.jar" />

                    <resource-root path="cassandra-driver-core-3.4.0.jar" />

                    <resource-root path="connector-cassandra-8.7.1.6_2-redhat-6.jar" />

                    <resource-root path="translator-cassandra-8.12.5.redhat-8.jar" />

                    <resource-root path="translator-cassandra-10.0.0.Alpha1.jar" />

                                    <resource-root path="libthrift-0.11.0.jar" />

                    <resource-root path="cassandra-jdbc-wrapper-3.1.0.jar"/>

                    <resource-root path="slf4j-jdk14-1.7.24.jar"/>

                     

                    </resources>

                    <dependencies>

                        <module name="javax.api"/>

                    <module name="javax.transaction.api"/>

                    <module name="javax.resource.api"/>

                    <module name="org.slf4j"/>

                        <module name="sun.jdk" export="true" >

                           <imports>

                              <include path="sun/misc/Unsafe" />

                           </imports>

                        </module>

                    </dependencies>

                    </module>

                     

                    And change in  Driver as:

                     

                    <driver name="cassandra" module="org.apache.hadoop.cassandra">

                         <driver-class>org.apache.cassandra.cql.jdbc.CassandraDriver</driver-class>

                           </driver>

                     

                    I was able to add the driver but during the import i got the following error:

                     

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

                    at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:159)

                    at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92)

                    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)

                    ... 25 more

                    Caused by: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2062548992)!

                    at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:137)

                    at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:100)

                    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)

                    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:425)

                    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:321)

                    at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:225)

                    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:77)

                    at org.apache.cassandra.thrift.Cassandra$Client.recv_describe_cluster_name(Cassandra.java:1247)

                    at org.apache.cassandra.thrift.Cassandra$Client.describe_cluster_name(Cassandra.java:1235)

                    at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:130)

                    ... 27 more

                    • 8. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                      ANKIT LOHCHAB Newbie

                      Thanks, now i was able to connect successfully to cassandra but during import it gives the duplicate invoice table and the keyspace i am importing don't even have invoice table. following is the error:

                       

                      18:28:47,783 INFO  [com.datastax.driver.core.policies.DCAwareRoundRobinPolicy] (teiid-async-threads - 1) Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)

                      18:28:47,797 INFO  [com.datastax.driver.core.Cluster] (teiid-async-threads - 1) New Cassandra host uscdc01tlmap002.globalservices.bcdtravel.local/10.55.36.21:9042 added

                      18:28:47,798 INFO  [com.datastax.driver.core.Cluster] (teiid-async-threads - 1) New Cassandra host /10.55.36.151:9042 added

                      18:28:47,798 INFO  [com.datastax.driver.core.Cluster] (teiid-async-threads - 1) New Cassandra host /10.55.36.22:9042 added

                      18:28:49,217 INFO  [com.github.adejanovski.cassandra.jdbc.CassandraConnection] (teiid-async-threads - 1) Connected to cluster: %s

                       

                       

                      18:28:49,225 INFO  [com.github.adejanovski.cassandra.jdbc.CassandraConnection] (teiid-async-threads - 1) Datacenter: %s; Host: %s; Rack: %s

                       

                       

                      18:28:49,225 INFO  [com.github.adejanovski.cassandra.jdbc.CassandraConnection] (teiid-async-threads - 1) Datacenter: %s; Host: %s; Rack: %s

                       

                       

                      18:28:49,225 INFO  [com.github.adejanovski.cassandra.jdbc.CassandraConnection] (teiid-async-threads - 1) Datacenter: %s; Host: %s; Rack: %s

                       

                       

                      18:28:49,226 INFO  [org.teiid.CONNECTOR] (teiid-async-threads - 1) JDBCExecutionFactory Commit=true;DatabaseProductName=Cassandra;DatabaseProductVersion=3.11.0;DriverMajorVersion=2;DriverMajorVersion=1;DriverName=Datastax JDBC Driver;DriverVersion=2.1.6;IsolationLevel=0

                      18:28:49,255 WARN  [org.teiid.RUNTIME] (teiid-async-threads - 1) TEIID50036 VDB importVDB2.1 model "importVDB2SrcModel" metadata failed to load. Reason:TEIID60013 Duplicate Table invoice: org.teiid.metadata.DuplicateRecordException: TEIID60013 Duplicate Table invoice

                      at org.teiid.metadata.Schema.addTable(Schema.java:49) [teiid-api-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at org.teiid.metadata.MetadataFactory.addTable(MetadataFactory.java:220) [teiid-api-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at org.teiid.translator.jdbc.JDBCMetdataProcessor.addTable(JDBCMetdataProcessor.java:344)

                      at org.teiid.translator.jdbc.JDBCMetdataProcessor.addTable(JDBCMetdataProcessor.java:327)

                      at org.teiid.translator.jdbc.JDBCMetdataProcessor.getTables(JDBCMetdataProcessor.java:300)

                      at org.teiid.translator.jdbc.JDBCMetdataProcessor.getConnectorMetadata(JDBCMetdataProcessor.java:159)

                      at org.teiid.translator.jdbc.JDBCExecutionFactory.getMetadata(JDBCExecutionFactory.java:298)

                      at org.teiid.translator.jdbc.JDBCExecutionFactory.getMetadata(JDBCExecutionFactory.java:68)

                      at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:96) [teiid-engine-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:62) [teiid-engine-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:55) [teiid-engine-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at org.teiid.jboss.VDBService$6.run(VDBService.java:395) [teiid-jboss-integration-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at org.teiid.jboss.VDBService$7.run(VDBService.java:446) [teiid-jboss-integration-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_121]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_121]

                      at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_121]

                      at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                      • 9. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                        Wolfgang Mayer Master

                        This appears to be related to Teiid. I'd suggest to post your issue in the Teiid forum. But the issue may be related to your DDL and you may also check this post  Multisource - Duplicate Table when adding metadata

                        • 10. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                          ANKIT LOHCHAB Newbie

                          Thanks!

                          We are including keyspace name while importing the data from Datasource but by default it is pointing to all tables irrespective of defined keyspace thats why it was giving duplicate table error. But now i have only kept two keyspaces with unique tables , and now while importing it is giving null point exception as bellow :

                           

                          WARN  [org.teiid.RUNTIME] (teiid-async-threads - 4) TEIID50036 VDB importVDB2.1 model "importVDB2SrcModel" metadata failed to load. Reason:java.lang.NullPointerException: java.lang.NullPointerException

                          at com.github.adejanovski.cassandra.jdbc.MetadataResultSets.makeColumns(MetadataResultSets.java:163)

                          at com.github.adejanovski.cassandra.jdbc.CassandraDatabaseMetaData.getColumns(CassandraDatabaseMetaData.java:135)

                          at org.teiid.translator.jdbc.JDBCMetdataProcessor.getColumns(JDBCMetdataProcessor.java:360)

                          at org.teiid.translator.jdbc.JDBCMetdataProcessor.getTables(JDBCMetdataProcessor.java:312)

                          at org.teiid.translator.jdbc.JDBCMetdataProcessor.getConnectorMetadata(JDBCMetdataProcessor.java:159)

                          at org.teiid.translator.jdbc.JDBCExecutionFactory.getMetadata(JDBCExecutionFactory.java:298)

                          at org.teiid.translator.jdbc.JDBCExecutionFactory.getMetadata(JDBCExecutionFactory.java:68)

                          at org.teiid.query.metadata.NativeMetadataRepository.getMetadata(NativeMetadataRepository.java:96) [teiid-engine-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                          at org.teiid.query.metadata.NativeMetadataRepository.loadMetadata(NativeMetadataRepository.java:62) [teiid-engine-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                          at org.teiid.query.metadata.ChainingMetadataRepository.loadMetadata(ChainingMetadataRepository.java:55) [teiid-engine-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                          at org.teiid.jboss.VDBService$6.run(VDBService.java:395) [teiid-jboss-integration-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                          at org.teiid.jboss.VDBService$7.run(VDBService.java:446) [teiid-jboss-integration-8.12.5.redhat-8.jar:8.12.5.redhat-8]

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_121]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_121]

                          at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_121]

                          at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                          • 11. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                            ANKIT LOHCHAB Newbie

                            Following is my Module.xml file through which my connection is successfull :-

                            <module xmlns="urn:jboss:module:1.3" name="org.apache.hadoop.cassandra">

                            <resources>

                                <resource-root path="cassandra-jdbc-wrapper-3.0.0.jar"/>

                                <resource-root path="slf4j-jdk14-1.7.24.jar"/>

                            </resources>

                            <dependencies>

                                <module name="javax.api"/>

                                <module name="javax.transaction.api"/>

                                <module name="sun.jdk" export="true" >

                                   <imports>

                                      <include path="sun/misc/Unsafe" />

                                   </imports>

                                </module>

                            </dependencies>

                            </module>

                             

                            Driver as follows:-

                            <driver name="cassandra" module="org.apache.hadoop.cassandra">

                                    <driver-class>org.apache.cassandra2.cql.jdbc.CassandraDriver</driver-class>

                            </driver>

                             

                            Following is the error while importing data:-

                             

                            INFO  [org.teiid.CONNECTOR] (Worker1_async-teiid-threads1) JDBCExecutionFactory Commit=true;DatabaseProductName=Cassandra;DatabaseProductVersion=3.11.0;DriverMajorVersion=2;DriverMajorVersion=1;DriverName=Datastax JDBC Driver;DriverVersion=2.1.6;IsolationLevel=0

                            16:31:26,751 WARN  [org.teiid.RUNTIME] (Worker1_async-teiid-threads1)  TEIID50036 VDB importVDB.1 model "importVDBSrcModel" metadata failed to load. Reason:java.lang.NullPointerException: java.lang.NullPointerException

                             

                            In the JDBCExecutionFactory the driver version is 2.1.6 , and with reference to this post Java Driver for Apache Cassandra - Native protocol - There is a matching protocol version (v3), but the driver 2.1.x can’t read the new system table format of Cassandra 3.x.

                             

                            Can anyone suggest from where I can download the correct driver jar for cassandra version 3.11 .

                             

                             

                            • 12. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                              Wolfgang Mayer Master

                              I am not sure understanding your question. I have no issues accessing Cassandra  (version: 3.11.2) via org.apache.cassandra2.cql.jdbc.CassandraDriver.

                              I don't think the above message is related to the driver which is part of cassandra-jdbc-wrapper-3.1.0.jar.

                               

                              To be sure you may decide to write a small java class which accesses the database directly.

                              • 13. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                                ANKIT LOHCHAB Newbie

                                But I am not able to do import metadata from cassandra using teiid designer on Jboss Developer studio using this configuration of jars .

                                • 14. Re: Can't established connection of cassandraDB(cassandra version 3) on wildfly10.1.0
                                  Wolfgang Mayer Master

                                  Again. I think this is related to Teiid and I suggest to ask thi question in that forum. Maybe your VDB is corrupted and you should re create it again.

                                  (Btw. regarding to you driver question I think you mixed the JDBC and native driver versions. Cluster.getDriverVersion() returns the version of the native driver (3.0.0) .You may check the latest supported protocol via ProtocolVersion.NEWEST_SUPPORTED))