4 Replies Latest reply on Feb 28, 2017 4:27 PM by Lebron James

    Wildfly 10 cannot find my cassandra jdbc driver.

    Lebron James Newbie

      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.
          Tomaz Cerar Master

             <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.
            Lebron James Newbie

            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.
              Wolfgang Mayer Master

              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.
                Lebron James Newbie

                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!