JBoss Server中的MongoDB数据源配置

时间:2017-07-06 18:38:47

标签: java mongodb jboss datasource jndi

如何在JBoss Server中配置MongoDB DataSource JNDI。 我下载了MongoDB jar( mongo-java-driver-3.4.2.jar )并使用管理控制台部署,它已成功部署,但当我在自定义选项中添加数据源时,我无法看到MongoDB驱动程序,唯一可用的选项是h2。为什么这样?我是否必须进行任何其他配置更改,或者我是否缺少任何步骤?

我甚至尝试手动创建MongoDB驱动程序和数据源,但这也无法正常工作。 我将module.xml和mongo-java-driver- 3.4.2.jar放到以下路径中 .. \ DEVSTUDIO \运行时\的JBoss-EAP \模块\ SYSTEM \层\基\有机\ mongodb的\主

--------- module.xml ---------------------

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.mongodb">
<resources>
<resource-root path="mongo-java-driver-3.4.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

--------------standalone.xml ------------

<datasource jndi-name="java:jboss/datasources/mongodb" pool-name="mongodb" 
enabled="true" use-java-context="true">
  <connection-url>jdbc:mongodb://127.0.0.1:27017/example;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
   <driver>mongodb</driver>
 </datasource>
<driver name="mongodb" module="org.mongodb">
   <xa-datasource-class>mongodb.jdbc.MongoXADataSource</xa-datasource-class>
 </driver>

启动服务器时出现以下错误

("subsystem" => "datasources"),
("data-source" => "mongodb")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable 
dependencies" => [
"org.wildfly.data-source.mongodb is missing [jboss.jdbc-driver.mongodb]",
"jboss.driver-demander.java:jboss/datasources/mongodb is missing 
[jboss.jdbc-driver.mongodb]"
]}
23:51:44,277 ERROR [org.jboss.as.controller.management-operation] 
(Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "mongodb")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable 
dependencies" => [
"org.wildfly.data-source.mongodb is missing [jboss.jdbc-driver.mongodb]",
"jboss.driver-demander.java:jboss/datasources/mongodb is missing 
[jboss.jdbc-driver.mongodb]",
"org.wildfly.data-source.mongodb is missing [jboss.jdbc-driver.mongodb]"
]}

你能让我知道如何在JBoss Server中进行JNDI数据源配置吗?请详细解释,因为我是JNDI配置的新手