Wildfly 找不到 cassandra jdbc 驱动程序
Wildfly cannot find cassandra jdbc driver
我在将我的 cassandraDB 连接到 wildfly 时遇到问题。我正在使用 Cassandra 3.0.9 和 wildfly 10.1.0.Final.
当我启动 wildfly 服务器时,它会给我这样的错误:
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]"]}
这是我要添加的 standalone.xml cassandra 数据源:
...
<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>
...
这是我的 module.xml 我的 cassandra jdbc 驱动程序:
<?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>
我根据这个博客配置了我的 cassandra jdbc 驱动程序:
http://johnsanda.blogspot.com/2012/10/configuring-cassandra-jdbc-with-jboss.html
我使用的 jdbc 驱动目录是从这里下载的:
https://code.google.com/archive/a/apache-extras.org/p/cassandra-jdbc
我很确定目录和文件位于正确的位置。我在
中有module.xml
$WILDFLY_HOME/modules/system/layers/base/org/wildfly/extension/cassandra/main
及其依赖项。
我在
中有数据源 class
$WILDFLY_HOME/modules/system/layers/base/org/apache/cassandra/cql/jdbc
我可以看到数据源是通过我的 Wildfly 管理页面添加的。但是当我尝试测试连接时,它失败了。但是wildfly提供的exampleDS完美运行。
我不知道这是怎么回事。是不是因为某些版本兼容问题?但是我没有看到cassandra在他们的主页上提供他们的官方jdbc驱动程序。
有人请帮助我!
其实,刚刚有人帮了我一把。
这里是wildfly论坛关于解决这个问题的link:
https://developer.jboss.org/thread/274131
我在将我的 cassandraDB 连接到 wildfly 时遇到问题。我正在使用 Cassandra 3.0.9 和 wildfly 10.1.0.Final.
当我启动 wildfly 服务器时,它会给我这样的错误:
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]"]}
这是我要添加的 standalone.xml cassandra 数据源:
...
<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>
...
这是我的 module.xml 我的 cassandra jdbc 驱动程序:
<?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>
我根据这个博客配置了我的 cassandra jdbc 驱动程序: http://johnsanda.blogspot.com/2012/10/configuring-cassandra-jdbc-with-jboss.html
我使用的 jdbc 驱动目录是从这里下载的:
https://code.google.com/archive/a/apache-extras.org/p/cassandra-jdbc
我很确定目录和文件位于正确的位置。我在
中有module.xml$WILDFLY_HOME/modules/system/layers/base/org/wildfly/extension/cassandra/main
及其依赖项。
我在
中有数据源 class$WILDFLY_HOME/modules/system/layers/base/org/apache/cassandra/cql/jdbc
我可以看到数据源是通过我的 Wildfly 管理页面添加的。但是当我尝试测试连接时,它失败了。但是wildfly提供的exampleDS完美运行。
我不知道这是怎么回事。是不是因为某些版本兼容问题?但是我没有看到cassandra在他们的主页上提供他们的官方jdbc驱动程序。
有人请帮助我!
其实,刚刚有人帮了我一把。 这里是wildfly论坛关于解决这个问题的link: https://developer.jboss.org/thread/274131