How to configure MongoDB DataSource JNDI in JBoss Server.
I downloaded MongoDB jar (mongo-java-driver-3.4.2.jar) and deployed using admin console, it got successfully deployed but when I went to add Datasource in customize option I am not able to see MongoDB driver, the only one option available was h2. Why so? Do I have to do any other configuration change or am I missing any step?
I Even tried to manually create the MongoDB driver and datasource but that is also not working.
I placed module.xml and mongo-java-driver- 3.4.2.jar to the following path
..\devstudio\runtimes\jboss-eap\modules\system\layers\base\org\mongodb\main
--------- 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>
I was getting the following error when i started the server
("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]"
]}
Could you let me know how to do JNDI Datasource configuration in JBoss Server ?? Please explain in detail as I am new for JNDI Configuration
Refer https://www.progress.com/blogs/configure-connect-for-jdbc-mongodb-driver-with-jboss-eap-64enter link description here
Related
I am using Thorntail (2.6.0) for the first time and have Problems connecting it to my Mysql Database (8.0.18)
I get the following Exception
2019-12-22 17:43:08,832 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 48) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]) - failure description: "WFLYJCA0114: Failed to load datasource class: com.mysql.cj.jdbc.MysqlXADataSource"
Followed by this Exception
2019-12-22 17:43:09,981 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "MainDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.MainDS is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/MainDS is missing [jboss.jdbc-driver.mysql]"
]
}
2019-12-22 17:43:09,982 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "MainDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.mysql",
"jboss.jdbc-driver.mysql"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.MainDS is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/MainDS is missing [jboss.jdbc-driver.mysql]",
"org.wildfly.data-source.MainDS is missing [jboss.jdbc-driver.mysql]"
]
}
The Following Settings I already did
I have JAVA_HOME should be Java 8 Zulu on a MacBook with Catalina
I have a module ../src/main/resources/modules/com/mysql/main/module.xml with the Following inside
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-8.0.18.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
My Persistence.xml in ../src/main/resources/META-INF/persistence.xml has this inside
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="SPU" transaction-type="JTA">
<!-- The "Java-Transaction-API" datasource here refers to the datasource defined in /src/main/resources/project-defaults.yml. -->
<jta-data-source>java:jboss/datasources/MainDS</jta-data-source>
<!-- User and password defines in project-defaults.yml -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
and my project-defaults.yml in ../src/main/resources/project-defaults.yml has this inside
thorntail:
datasources:
jdbc-drivers:
mysql:
driver-module-name: com.mysql
driver-xa-datasource-class-name: com.mysql.cj.jdbc.MysqlXADataSource
data-sources:
MainDS:
driver-name: mysql
connection-url: jdbc:mysql://localhost:3306/Mysql
user-name: ****
password: ****
I have this in my pom:
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>datasources</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${version.mysql}</version>
</dependency>
My Database is running and this should be not the problem.
I also read somewhere that there is an error in WildFly, stopping thorntail in finding com.mysql.cj.jdbc.MysqlXADataSource.
I thank everyone who tries to help me, I have this problem the whole day already.
My Goal is a Java-EE Server (FatJar) with JPA and a MySQL Database at the back.
Thorntail can autodetect many JDBC drivers, MySQL included. You don't have to create the module.xml file, and the thorntail.datasources.jdbc-drivers.mysql piece of configuration also isn't necessary. It should be enough to have a dependency on the JDBC driver (which you have), and define the datasource (which you also do). The driver-name should be mysql, which you also already have.
See https://docs.thorntail.io/2.6.0.Final/#auto-detecting-jdbc-drivers_thorntail and https://docs.thorntail.io/2.6.0.Final/#_datasources for more info.
I am migrating my project from JBoss EAP 6.4 to JBoss EAP 7.2.
So I am getting this kind of error,
15:45:50,571 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "my.war")]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.DefaultDataSource"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.dummy.env.myDS is missing [jboss.naming.context.java.module..DefaultDataSource]"]
}
I got to know that this error occurs because default data source is not defined in standalone.xml. In previous versions of JBoss EAP removing DefaultDataSource was not giving this issue. In this version defining DefaultDataSource is mandatory even though those applications do not need that default data source.
So I tried giving default data source as an already existing datasource. In this kind of statement:
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:/jdbc/existing" />
And this worked fine.
Now my problem is our environment has multiple databases and their respective data sources.
So we can't define a particular data source as a default. As this will interfere with our applications regular flow. And can create major issues.
We want the application to use their specific data sources only not the default one.
But JBoss EAP 7 is forcing us to specify default data source.
So we can define a dummy default data source? or is there any other alternative way?
default datasource option is present in default binding in standalone.xml
default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/jdbc/jndi-name" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/
Applicable to both JBoss EAP 7.2 and Wildfly :
Modify this part of standalone.xml to set the default datasource :
<?xml version="1.0" encoding="UTF-8"?>
<subsystem xmlns="urn:jboss:domain:datasources:3.0">
<datasources>
<datasource jta="true" jndi-name="java:jboss/datasources/default" pool-name="default" enabled="true" use-java-context="true" use-ccm="true" statistics-enabled="true">
<connection-url>jdbc:mysql://localhost:3306/default?autoReconnect=true&useSSL=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
JBoss/Wildfly will pick up this as an default datasource.
Hope this helps you :)
I have to push messages from one jobss server and consume from another jboss server. For that I used jms bridge.
Added jms bridge configuration under </hornetq-server> tag in
standalone-full.xml and also referred dependencies via module.
<jms-bridge name="simpleBridge" module="org.jboss.messaging">
<source>
<connection-factory name="ConnectionFactory"/>
<destination name="java:/simpleSOurceQ"/>
</source>
<target>
<connection-factory name="RemoteConnectionFactory"/>
<destination name="/queue/simpleTargetQ"/>
<context>
<property key="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
<property key="java.naming.provider.url" value="remote://TARGET_URL:5445"/>
</context>
</target>
<quality-of-service>DUPLICATES_OK</quality-of-service>
<failure-retry-interval>500</failure-retry-interval>
<max-retries>1</max-retries>
<max-batch-size>500</max-batch-size>
<max-batch-time>500</max-batch-time>
<add-messageID-in-header>true</add-messageID-in-header>
</jms-bridge>
Deployment time, getting below ERROR in jboss,
ERROR LOG :
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014612: Operation ("add") failed - address: ([
("subsystem" => "messaging"),
("jms-bridge" => "simpleBridge")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.messaging.jms-bridge.simpleBridge is missing [jboss.naming.context.java.simpleSourceQ]"]}
How to resolve this?
or Is there anyway to achieve this?
The bridge's source is defined as:
<source>
<connection-factory name="ConnectionFactory"/>
<destination name="java:/simpleSOurceQ"/>
</source>
However, according to a comment your jms-queue is defined as:
<jms-queue name="simpleSourceQ">
<entry name="jms/queue/simpleSourceQ"/>
<entry name="java:jboss/exported/jms/queue/simpleSourceQ"/>
<durable>true</durable>
</jms-queue>
As you can see, the destination name from the source doesn't match any of the entry elements from the jms-queue therefore the bridge dependencies are not met. The bridge's source should reference a valid JNDI entry of the jms-queue.
I'm trying to migrate from Glassfish to WildFly 10, my app connects whit Sybase ASE database. I put jconn3.jar in WILDFLY_HOME\modules\system\layers\base\com\sybase\sybase\main, created modules.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.sybase.sybase">
<resources>
<resource-root path="jconn3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
and inserted to the standalone.xml:
<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 jndi-name="java:jboss/datasources/FRAME_IBS" pool-name="FRAME_IBS" enabled="true" use-java-context="true">
<connection-url>jdbc:sybase:Tds:localhost:5000/Banksys;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>sybase</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<driver-class>
com.sybase.jdbc3.jdbc.SybDriver
</driver-class>
<security>
<user-name>admin</user-name>
<password>admin</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="sybase" module="com.sybase.sybase">
<datasource-class>com.sybase.jdbc3.jdbc.SybDataSource</datasource-class>
<xa-datasource-class>com.sybase.jdbc3.jdbc.SybXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
I got this error in server.log file when I started WF:
2017-02-17 12:48:56,297 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "FRAME_IBS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.sybase"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/FRAME_IBS is missing [jboss.jdbc-driver.sybase]",
"org.wildfly.data-source.FRAME_IBS is missing [jboss.jdbc-driver.sybase]"
]
}
2017-02-17 12:48:56,297 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "FRAME_IBS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.sybase",
"jboss.jdbc-driver.sybase"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/FRAME_IBS is missing [jboss.jdbc-driver.sybase]",
"org.wildfly.data-source.FRAME_IBS is missing [jboss.jdbc-driver.sybase]",
"org.wildfly.data-source.FRAME_IBS is missing [jboss.jdbc-driver.sybase]"
]
}
2017-02-17 12:48:56,453 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.sybase (missing) dependents: [service org.wildfly.data-source.FRAME_IBS, service jboss.driver-demander.java:jboss/datasources/FRAME_IBS]
I googled it and tried all that I found but still have this error. Please, help me.
Excuse if my english it´s not correct, it's not my native language.
I rename module and move it to WILDFLY_HOME\modules following Leozeo and Mark recommendations, and still have the same message. I remove my datasource from standalone.xml, run WF again, and I se this message:
ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "sybase")
File module.xml and .jar are both present now in WILDFLY_HOME\modules
Make sure you have driver installed properly. Check for driver jar and modules.xml file is present at under WILDFLY_HOME\modules\system\layers\base\com\sybase\main directory.
update value of name attribute
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.sybase">
<resources>
<resource-root path="jconn3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
I am new in JBoss and I try to add a jdbc driver for derby as a module in WidlFly 8.2.0.
What I did:
I added the org/apache/derby/main folder in the JBOSS_HOME/modules/system/layers/base directory
In this new folder, I added derbyclient.jar (from jdk 1.8.0_40, it contains the driver) and a new module.xml file.
The module.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.apache.derby">
<resources>
<resource-root path="derbyclient.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Then, I updated the standalone.xml file as follows:
addition of this tag (in <extensions>): <extension module="org.apache.derby"/>
Declaration of my datasource and of the driver:
<datasource jndi-name="java:/DerbyDS" pool-name="DerbyDS" enabled="true" use-ccm="false">
<connection-url>jdbc:derby:MyDB;create=true</connection-url>
<driver>org.apache.derby</driver>
<security>
<user-name>demo</user-name>
<password>demo</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="org.apache.derby" module="org.apache.derby">
<xa-datasource-class>org.apache.derby.jdbc.ClientXADataSource</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
I am getting the following error when I start WildFly:
`16:19:49,856 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "DerbyDS")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]",
"jboss.driver-demander.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]"
]}
16:19:49,866 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "DerbyDS")
]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]",
"jboss.driver-demander.java:/DerbyDS is missing [jboss.jdbc-driver.org_apache_derby]"
],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.data-source.reference-factory.DerbyDS",
"jboss.naming.context.java.DerbyDS"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.org_apache_derby"]
}
}
16:19:49,897 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "MyApp.ear" (runtime-name : "MyApp.ear")
16:19:49,897 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "MyApp2.ear" (runtime-name : "MyApp2.ear")
16:19:49,907 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.org_apache_derby (missing) dependents: [service jboss.driver-demander.java:/DerbyDS, service jboss.data-source.java:/DerbyDS]`
Do you know what I did wrong?
Thanks in advance
I finally solved the issue by:
adding derbyclient.jar in the standalone directory (where my applications are deployed)
modifying the datasource declaration in the standalone.xml to make it reference the jar name :
<datasource jndi-name="java:/DerbyDS" pool-name="DerbyDS"enabled="true" use-ccm="false"> <connection-url>jdbc:derby:MyDB;create=true</connection-url> <driver>derbyclient.jar</driver>...
(I deleted the <drivers> tag, I don't use it anymore.)
So, I don't have errors anymore when I start WildFly. The derby driver is not declared as a module, but it will be shared among my different applications, so that's ok.
Your URL jdbc:derby://:MyDB looks invalid.