10 Replies Latest reply on Apr 16, 2018 9:11 AM by alohchab

    Wildfly 10 cannot find my cassandra jdbc driver.

    sensorhound-nan

      0 down vote  favorite  

       

      I have problem connect my cassandraDB to wildfly. I am using Cassandra 3.0.9 and wildfly 10.1.0.Final.

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

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

        ([("subsystem" => "datasources"),

        ("data-source" => "cassandraDS")

      ]) - failure description: {

        "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.cassandra"],

        "WFLYCTL0180: Services with missing/unavailable dependencies" =>

        ["jboss.driver-demander.java:jboss/datasources/cassandraDS is missing [jboss.jdbc-driver.cassandra]",

        "org.wildfly.data-source.cassandraDS is missing [jboss.jdbc-driver.cassandra]"

      ]

      }

      Here is my standalone.xml to add cassandra datasource:

      ... 
      <subsystem xmlns="urn:jboss:domain:datasources:4.0">
      <datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
          <driver>h2</driver>
          <security>
            <user-name>sa</user-name>
            <password>sa</password>
          </security>
        </datasource>
        <datasource jta="false" jndi-name="java:jboss/datasources/cassandraDS"
         pool-name="cassandraDS" enabled="true" use-java-context="true" use-ccm="false">
          <connection-url>jdbc:cassandra://localhost:9042</connection-url>
          <driver>cassandra</driver>
        </datasource>
        <drivers>
          <driver name="h2" module="com.h2database.h2">
            <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
          </driver>
          <driver name="cassandra" module="org.wildfly.extension.cassandra">
            <datasource-class>org.apache.cassandra.cql.jdbc.CassandraDataSource</datasource-class>
          </driver>
        </drivers>
      </datasources>
      </subsystem> ...

      And here is my module.xml for my cassandra jdbc driver:

      <?xml version="1.0" encoding="UTF-8"?> 
      <module xmlns="urn:jboss:module:1.0" name="org.wildfly.extension.cassandra">
      <properties>
        <property name="jboss.api" value="private"/>
      </properties>

      <resources>

      <!-- the subsystem itself -->
      <resource-root path="wildfly-cassandra.jar"/> 

      <!-- cassandra libs -->
        <resource-root path="cassandra-all-2.1.5.jar"/>
        <resource-root path="cassandra-thrift-2.1.5.jar"/> 

      <!-- cassandra dependencies -->
        <resource-root path="ST4-4.0.8.jar"/>
        <resource-root path="antlr-3.5.2.jar"/>
        <resource-root path="antlr-runtime-3.5.2.jar"/>
        <resource-root path="commons-cli-1.1.jar"/>
        <resource-root path="commons-codec-1.2.jar"/>
        <resource-root path="commons-lang3-3.1.jar"/>
        <resource-root path="commons-math3-3.2.jar"/>
        <resource-root path="compress-lzf-0.8.4.jar"/>
        <resource-root path="concurrentlinkedhashmap-lru-1.4.jar"/>
        <resource-root path="disruptor-3.0.1.jar"/>
        <resource-root path="fastutil-6.5.7.jar"/>
        <resource-root path="guava-16.0.jar"/>
        <resource-root path="hibernate-validator-4.3.0.Final.jar"/>
        <resource-root path="high-scale-lib-1.0.6.jar"/>
        <resource-root path="httpclient-4.2.5.jar"/>
        <resource-root path="httpcore-4.2.4.jar"/>
        <resource-root path="jackson-core-asl-1.9.2.jar"/>
        <resource-root path="jackson-mapper-asl-1.9.2.jar"/>
        <resource-root path="jamm-0.3.0.jar"/>
        <resource-root path="jbcrypt-0.3m.jar"/>
        <resource-root path="jline-1.0.jar"/>
        <resource-root path="jna-4.0.0.jar"/>
        <resource-root path="json-simple-1.1.jar"/>
        <resource-root path="libthrift-0.9.2.jar"/>
        <resource-root path="lz4-1.2.0.jar"/>
        <resource-root path="metrics-core-2.2.0.jar"/>
        <resource-root path="netty-all-4.0.23.Final.jar"/>
        <resource-root path="reporter-config-2.1.0.jar"/>
        <resource-root path="snakeyaml-1.13.jar"/>
        <resource-root path="snappy-java-1.0.5.jar"/>
        <resource-root path="stream-2.5.2.jar"/>
        <resource-root path="super-csv-2.1.0.jar"/>
        <resource-root path="thrift-server-0.3.7.jar"/>
        <resource-root path="validation-api-1.0.0.GA.jar"/>

        <!-- the configuration overlays -->
        <resource-root path="conf"/>
      </resources> 

      <dependencies>
        <module name="org.slf4j"/>
        <module name="javax.api"/>
        <module name="org.jboss.staxmapper"/>
        <module name="org.jboss.as.controller"/>
        <module name="org.jboss.as.server"/>
        <module name="org.jboss.modules"/>
        <module name="org.jboss.msc"/>
        <module name="org.jboss.logging"/>
        <module name="org.jboss.vfs"/>
        <module name="sun.jdk"/>
        <!-- access to sun.misc.Unsafe -->
      </dependencies>

      I have my cassandra jdbc driver configured according to this blog: http://johnsanda.blogspot.com/2012/10/configuring-cassandra-jdbc-with-jboss.html

      And the jdbc driver dir I use is downloaded from here:

      https://code.google.com/archive/a/apache-extras.org/p/cassandra-jdbc

      I am pretty sure I have the directories and files are in the right places. I have the module.xml in

      $WILDFLY_HOME/modules/system/layers/base/org/wildfly/extension/cassandra/main

      along with its dependencies.

      And I have the datasource class in

      $WILDFLY_HOME/modules/system/layers/base/org/apache/cassandra/cql/jdbc

      I can see the datasource is added through my wildfly admin page. But when I try to test connection, it failed. But the exampleDS provided by wildfly worked perfect.

      I don't know what is going on. Is there because of some version compatibility problems? But I didn't see cassandra providing their official jdbc driver on their homepage.

      Someone please help me!

        • 1. Re: Wildfly 10 cannot find my cassandra jdbc driver.
          ctomc

             <driver name="cassandra" module="org.wildfly.extension.cassandra">
                <datasource-class>org.apache.cassandra.cql.jdbc.CassandraDataSource</datasource-class>
              </driver>

           

          This config says you have jdbc driver in module org.wildfly.extension.cassandra.

          but later on you say you have it in

          $WILDFLY_HOME/modules/system/layers/base/org/apache/cassandra/cql/jdbc

          Which would mean module name is org.apache.cassandra.cql.jdbc

          given that you have proper module.xml in $WILDFLY_HOME/modules/system/layers/base/org/apache/cassandra/cql/jdbc/main

          • 2. Re: Wildfly 10 cannot find my cassandra jdbc driver.
            sensorhound-nan

            Hi, Tomaz, thank you for your comments.

             

            I have my module.xml and a lot of jars in:

            $WILDFLY_HOME/modules/system/layers/base/org/wildfly/extension/cassandra/main

             

            And I have a lot of classes like the CassandraDataSource.class in:

            $WILDFLY_HOME/modules/system/layers/base/org/apache/cassandra/cql/jdbc

             

            According to the tutorial I have, it seems to me that module="org.wildfly.extension.cassandra" tells wildfly where to find the jdbc driver. And <datasource-class>org.apache.cassandra.cql.jdbc.CassandraDataSource</datasource-class> tells wildfly where the actual data source is. So I don't know where is the problem. I don't have any class file in my $WILDFLY_HOME/modules/system/layers/base/org/wildfly/extension/cassandra/main directory.

             

            Thanks!

            • 3. Re: Wildfly 10 cannot find my cassandra jdbc driver.
              mayerw01

              Have you been successful with connecting to Cassandra via a plain Java class using JDBC?

              Your documentation also seems to be quite old.

              Apparently there had also been some changes in the schema ([CASSANDRA-10996] The system table system.schema_columnfamilies does not exist - ASF JIRA )

              At least in my environment I've got no other JDBC driver working beside of  the jdbc wrapper (GitHub - adejanovski/cassandra-jdbc-wrapper: A JDBC wrapper for the Datastax Java Driver for Cassandra)

              But here the configuration in WildFly is rather simple

              1. Copy cassandra-jdbc-wrapper-3.1.0.jar to $JBOSS_HOME/modules/org/cassandra/main/
              2. Create module.xml in $JBOSS_HOME/modules/org/cassandra/main
              3. To avoid SLF4J errors you should also copy slf4j-jdk14-1.7.24.jar

               

              <module xmlns="urn:jboss:module:1.3" name="org.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>

               

               

               

              create the driver via cli:

              /subsystem=datasources/jdbc-driver=cassandra:add(driver-name=cassandra,driver-module-name=org.cassandra,driver-class-name=org.apache.cassandra2.cql.jdbc.CassandraDriver)

              • 4. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                sensorhound-nan

                Hi, Wolfgang, thanks a lot! I have successfully added cassandra datasource to my wildfly app server using this jdbc driver.

                 

                One thing to mention is that the git repository cannot complete the whole "mvn clean install", there will an error when doing that, but it still generates the cassandra-jdbc-wrapper-3.1.0.jar we need.

                 

                And I downloaded slf4j-jdk14-1.7.24.jar from Maven Repository: org.slf4j » slf4j-jdk14  rather than copy it from the git repository.

                 

                Thanks a lot!

                • 5. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                  alohchab

                  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!

                  • 6. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                    mayerw01

                    As mentioned above the driver path is org.apache.cassandra2.cql.jdbc.CassandraDriver

                    • 7. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                      alohchab

                      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]"

                      • 8. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                        mayerw01

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

                        • 9. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                          alohchab

                          it is placed at this location only but still give the same 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]".

                          • 10. Re: Wildfly 10 cannot find my cassandra jdbc driver.
                            alohchab

                            Module location is  $JBOSS_HOME/modules\system\layers\dv\org\apache\hadoop\cassandra\main

                             

                            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