在JBOSS7中安装MariaDB Java连接器
我很难在使用MariaDB的JBOSS7上部署EJBCA 6。我已将EJBCA配置为使用JBOSS standalone。使用默认H2数据库后端时,我的配置有效。我在JBOSS standalone.xml中配置了mariadb Java连接器
<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</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mariadb" module="org.mariadb.jdbc">
<xa-datasource-class>org.mariadb.jdbc.MySQLDataSource</xa-datasource-class>
</driver>
</drivers>
<datasource jndi-name="java:/MariaDS" pool-name="MariaDS" enabled="false">
<connection-url>jdbc:mariadb://localhost:3306/ejbca</connection-url>
<driver>mariadb</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>100</min-pool-size>
<max-pool-size>200</max-pool-size>
</pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
</datasources>
我将MariaDB Java连接器复制到JBOSS_HOME / modules / org / mariadb / jdbc / main / mariadb-java-client-1.1.5.jar并配置了这样的module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.mariadb.jdbc">
<resources>
<resource-root path="mariadb-java-client-1.1.5.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
MariaDB驱动程序列在boot.log和server.log中。它也通过jboss-cli列出:
[standalone@localhost:9999 /] /subsystem=datasources:installed-drivers-list
{
"outcome" => "success",
"result" => [
{
"driver-name" => "mariadb",
"deployment-name" => undefined,
"driver-module-name" => "org.mariadb.jdbc",
"module-slot" => "main",
"driver-datasource-class-name" => "",
"driver-xa-datasource-class-name" => "org.mariadb.jdbc.MySQLDataSource",
"driver-class-name" => "org.mariadb.jdbc.Driver",
"driver-major-version" => 1,
"driver-minor-version" => 1,
"jdbc-compliant" => false
},
{
"driver-name" => "h2",
"deployment-name" => undefined,
"driver-module-name" => "com.h2database.h2",
"module-slot" => "main",
"driver-datasource-class-name" => "",
"driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource",
"driver-class-name" => "org.h2.Driver",
"driver-major-version" => 1,
"driver-minor-version" => 3,
"jdbc-compliant" => true
}
]
}
我已经像这样设置了EJBCA database.properties:
database.driver=org.mariadb.jdbc.Driver
database.url=jdbc:mysql://hostname:3306/ejbca?characterEncoding=UTF
database.name=mysql
然而,当我尝试使用ant部署将EJBCA部署到JBOSS时,部署失败并显示:
jee:deployDSJBoss7:
[exec] Result: 1
[exec] Result: 1
[echo] data-source add --name=ejbcads --driver-name="org.mariadb.jdbc.Driver" --connection-url="jdbc:mysql://ejbca-test-05.vm:3306/ejbca?characterEncoding=UTF-8" --jndi-name="java:/EjbcaDS" --use-ccm=true --user-name="ejbca" --password="reverse" --validate-on-match=true --background-validation=false --prepared-statements-cache-size=50 --share-prepared-statements=true --min-pool-size=5 --max-pool-size=150 --pool-prefill=true --transaction-isolation=TRANSACTION_READ_COMMITTED --check-valid-connection-sql="select 1"
[exec] JBAS010468: Driver named "org.mariadb.jdbc.Driver" is not installed.
我做错了什么?
答案 0 :(得分:2)
有关module.xml的信息,请参阅以下示例。用你的
更新jar文件名<module xmlns="urn:jboss:module:1.1" name="org.mariadb">
<resources>
<resource-root path="mariadb-java-client-1.3.3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
请参阅下面的standalone.xml中的数据源配置或您使用的xml。根据您的需要替换IP /主机名,端口号,数据库名称(DB1),池名称,jndi-name。
<datasource jndi-name="java:jboss/MariaDBDS" pool-name="MariaDBDS" enabled="true" statistics-enabled="true">
<connection-url>jdbc:mariadb://10.92.142.148:6603/DB1</connection-url>
<driver>mariadb</driver>
<new-connection-sql>SELECT 1</new-connection-sql>
<security>
<user-name>your-database-username</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
稍后回到此部分并更新连接池
在驱动程序中添加以下内容
<driver name="mariadb" module="org.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
</driver>
启动jboss并检查控制台中的数据源并测试连接
答案 1 :(得分:0)
enabled = false不应该存在或者如下:
通常还有数据源元素和驱动元素。
有帮助吗?
答案 2 :(得分:0)
对我来说,在搜索了很多东西并收集了一些零碎的东西之后工作了
首先需要通过 jboss-cli 部署 Mariadb jar 文件,然后将模块添加到 org/mariadb/main/ 下
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="org.mariadb"> <resources> <resource-root path="mariadb-java-client-2.7.0.jar"/></resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
然后在 standalone.xml 中添加更改
<datasource jta="true" jndi-name="java:jboss/MariaDBDS" pool-name="MariaDBDS" enabled="true" use-ccm="false">
<connection-url>jdbc:mariadb://localhost:3306/DbName</connection-url>
<driver>mariadb-java-client-2.7.0.jar</driver>
<driver-class>org.mariadb.jdbc.Driver</driver-class>
<security>
<user-name>uname</user-name>
<password>pwd</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>