I am using jboss as 7.1.1 final release. I am trying to add mysql driver to the server via the admin console. I am able to do so but when I go to create the datasources, I do not find the driver listed there. I followed the steps to add the driver to the server as mentioned in this link :
http://www.appeon.com/support/documents/appeon_online_help/1.5/server_configuration_guide_for_j2ee/ch03s03s03.html#d0e4128
I followed from step 3 of Installing a JDBC driver via the Web console as I had already created one management user.To summarize what I did,
I added a driver file E:\DevSoftwares\servers\jboss\jboss-as-7.1.1.Final\modules\com\mysql\main\META-INF\services\java.sql.Driver and its content as following : com.mysql.jdbc.jdbc2.optional.MysqlXADataSource(fully qualified driver class name).
create module.xml file inside E:\DevSoftwares\servers\jboss\jboss-as-7.1.1.Final\modules\com\mysql\main\ and its content as below :
Added mysql-connector-java-5.0.8-bin.jar file inside E:\DevSoftwares\servers\jboss\jboss-as-7.1.1.Final\modules\com\mysql\main\
Ran jar -uf mysql-connector-java-5.0.8-bin.jar META-INF\services\java.sql.Driver command to modify the jar.
After running this command I could see a services\java.sql.Driver file with driver class name as given in step 1 inside META-INF folder of the jar file which was not there before running the command.
I picked up the fully qualified name of the driver class for mysql for Jboss 7.x from below link :
http://www.appeon.com/support/documents/appeon_online_help/1.5/server_configuration_guide_for_j2ee/ch03s03s07.html#d0e5769
I was able to figure out what is causing the problem, when I try to enable the deployed jar I get an exception in the server console stating : unable to instantiate driver class com.mysql.jdbc.jdbc2.optional.MysqlXADataSource :
java/lang.ClassCastException :
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.
However I checked the mysql-connector-java-5.0.8-bin.jar and was able to find the driver class mentioned above in the same directory structure as the classes fully qualified name.
I am not able to figure out why I am getting this exception or what I am doing wrong during the setup that is causing this issue.The platform I am using is windows. Could some one please help me with it.
NOTE : the content of module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.0.8-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>`
Please check that you have added your MySQL datasource configuration in standalone.xml or in equivalent XML file:-
<subsystem xmlns="urn:jboss:domain:datasources:1.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</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:jboss/datasources/MySqlExampleDS" pool-name="MySqlExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/jboss7db</connection-url>
<driver>mysql</driver>
<pool>
<max-pool-size>30</max-pool-size>
</pool>
<security>
<user-name>root</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="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
Related
I am trying to get to the underlaying Oracle connection in my WebApp on a JBoss Wildly 8.1 server.
I get an exception when I try to do the unwrap:
connection.unwrap(OracleConnection.class);
Throws
java.sql.SQLException: Not a wrapper for: oracle.jdbc.OracleConnection
The connection's class turns out to be com.sun.proxy.$Proxy37
This is my configuration in standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/myds" pool-name="MyPool" enabled="true">
<connection-url>jdbc:oracle:thin:#//host:152x/blabla</connection-url>
<driver>Oracle11g</driver>
<security>
<user-name>xxx</user-name>
<password>yyy</password>
</security>
</datasource>
<drivers>
<driver name="Oracle11g" module="com.oracle.ojdbc6">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
</drivers>
</datasources>
</subsystem>
How can I get to the OracleConnection?
Edit: I have configured the oracle driver in the standalone.xml and the driver is added in the modules folder. In order to be able to get my code compiled, I have added a dependency in my pom-file to the driver as well. No idea if this is part of the cause.
Thanks
I found the solution!
When using this statement I can get to the OracleConnection object:
(oracle.jdbc.driver.OracleConnection) conn.getMetaData().getConnection();
I have a web application I am deploying in wildfly-10.0.0. It requires a mysql xa driver. I have the following error:
2015-10-13 12:25:37,979 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "com.mysql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.mysql]"
The modules directory is as follows:
Directory of C:\Users\rball\Documents\Dev\WildFly\wildfly-10.0.0.CR1\modules\sy
stem\layers\base\com\mysql\main
10/13/2015 11:32 AM <DIR> .
10/13/2015 11:32 AM <DIR> ..
10/13/2015 12:25 PM 1,575 module.xml
03/17/2015 05:21 AM 968,670 mysql-connector-java-5.1.35-bin.jar
The module.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.35-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
I added the driver and datasource to the datasources section of standalone.xml:
<xa-datasource jndi-name="java:/jdbc/MyXaDS" pool-name="MyXaDSPool" enabled="true" use-ccm="false">
<xa-datasource-property name="URL">
jdbc:mysql://localhost:3306/temp?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
</xa-datasource-property>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<driver>com.mysql</driver>
<xa-pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<background-validation-millis>1000</background-validation-millis>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
The error you get means that wildfly expects a module called com.mysql but it doesn't exist or it isn't registered under that name.
You are missing one step, which is registering the datasource jdbc driver. The first step of course being adding the mysql-connector-java-5.1.35-bin.jar file and module.xml file in WILDFLY_HOME\modules\system\layers\base\com\mysql\main.
To get rid of your error, stop wildfly, delete the the driver declaration in your standalone.xml by removing these lines; We'll let the /subsystem command create this entry.
<driver name="com.mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
Open your command prompt and navigate to WILDFLY_HOME\bin\ and run the following commands.
Connect to jboss cli by running : jboss-cli.bat --connect . In case your management console is running on a different port say , localhost:9991, use jboss-cli.bat --connect --controller=127.0.0.1:9991
Then register the jdbc-driver with the following command
/subsystem=datasources/jdbc-driver=com.mysql:add(driver-name=com.mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
You should get the response {"outcome" => "success"} if this was successful.
From there, reload your server and you should get rid of that error.
I got pointers from This link
I'm not really sure what the issue could be. The message isn't very informative.
That said the following add-mysql.cli script worked for me.
module add --name=com.mysql --resources=~/Downloads/mysql-connector-java-5.1.37/mysql-connector-java-5.1.37-bin.jar --dependencies=javax.api,javax.transaction.api
batch
/subsystem=datasources/jdbc-driver=com.mysql:add(driver-name=com.mysql, driver-module-name=com.mysql, driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
/subsystem=datasources/xa-data-source=mysql:add(driver-name=com.mysql, jndi-name="java:/jdbc/MySQLXA", enabled=true)
/subsystem=datasources/xa-data-source=mysql/xa-datasource-properties=URL:add(value="jdbc:mysql://localhost:3306/temp?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8")
run-batch
I didn't write all the properties defined in your data source configuration, but this did work.
WildFly 10 has some change in jca caused CLI create xa ds have some issue.
https://issues.jboss.org/browse/WFLY-6773
https://issues.jboss.org/browse/WFLY-6789
https://issues.jboss.org/browse/WFLY-6774
But create xa datasouces use below commands works
xa-data-source add --name=MariaDBXADS --driver-name=mariadb-xa --jndi-name=java:jboss/datasources/MariaDBXADS --user-name=jdv_user --password=jdv_pass --use-java-context=true --xa-datasource-properties=[DatabaseName=>products, PortNumber=>3306, ServerName=>localhost]
WILDFLY 10 using MySQL 5.7
Follow these steps: comment or delete exampleds in standalone.xml
into jboss-cli.bat --connect
After execute command:
[standalone#localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
should be ok.
This modified standalone.xml, then add:
<datasources>
<!--
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-
<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:/mysql" pool-name="mysqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/wildfly</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>jdfoxito10</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>
should look like!
and module.xml put in
\java\server\wildfly-10.1.0.Final\modules\system\layers\base\com\mysql\main
mysql-connector-java-5.1.40-bin.jar (come installer mysql-installer-community-5.7.15.0.msi) module.xml
and content from module.xml like:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.40-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
and ready, JAVA_HOME should be ok
I have several Jboss EAP 6.1 installations working with Oracle driver installed as a module.
This is the standard configuration I use in standalone.xml:
<datasource jndi-name="java:jboss/fooDatasource" pool-name="java:jboss/fooDatasource" enabled="true" use-java-context="false" >
<connection-url>jdbc:oracle:thin:#1.2.3.4:1527/SOMEDB.foo</connection-url>
<driver>oracle</driver>
<security>
<user-name>xxxxx</user-name>
<password>xxxxxxxxx</password>
</security>
[...]
</datasource>
<driver name="oracle" module="oracle.jdbc">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<datasource-class>oracle.jdbc.OracleDriver</datasource-class>
</driver>
The ojdbc6.jar is in $JBOSS_HOME/modules/system/layers/base/oracle/jdbc/main/ together with the appropriate module.xml and everything works fine.
Now a customer required to install the driver as a deployment, so I moved ojdbc6.jar to $JBOSS_HOME/standalone/deployments/ and I see from logs that it is deployed without errors:
[org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
INFO [org.jboss.as.server] (ServerService Thread Pool -- 25) JBAS018559: Deployed "ojdbc6.jar" (runtime-name : "ojdbc6.jar")
But I don't know how to edit my standalone.xml to make it work again: i tried to edit the driver definition "module" attribute with several different values (ojdbc6.jar, deployment.ojdbc6.jar, oracle.jdbc.OracleDriver...) but none seem to "match" and Jboss keeps throwing errors at startup:
ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 24) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "oracle")
]) - failure description: "JBAS010441: Failed to load module for driver [ojdbc6.jar]"
[...]
INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.oracle (missing) dependents: [service jboss.driver-demander.java:jboss/spiDatasource, service jboss.data-source.java:jboss/fooDatasource]
Could anyone please provide a working example of the driver definition?
Thanks
Ok, I found the answer myself.
Surprisingly, all the guides I found around explain how to do this configuration via web admin interface or via jboss-cli, but no one in the Jboss community seem to bother explaining how to manually edit the standalone.xml to do the job.
This is a working example (basically I just deleted the entire Oracle driver definition section and replaced the driver name in the datasource definition with the name of the runtime name of the deployed jar file):
<datasource jta="false" jndi-name="java:/jdbc/fooDS" pool-name="foo-ds" use-ccm="false">
<connection-url>jdbc:oracle:thin:#1.2.3.4:1527/SOMEDB.foo</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc6.jar</driver>
[...] other datasource stuff here
</datasource>
# DELETE FROM HERE...
<driver name="oracle" module="oracle.jdbc">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<datasource-class>oracle.jdbc.OracleDriver</datasource-class>
</driver>
# ...TO HERE
That's all.
Probably you have to mention in this way...
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
<datasource jndi-name="java:jboss/XXX" pool-name="XXX" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:#SID:PORT:DBNAME</connection-url>
<driver>oracle</driver>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<datasource-class>oracle.jdbc.OracleDriver</datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
Create directories like x1/x2/main
Create module.xml file under main directory
Keep ojdbc6-11.1.1.3.0.jar in main directory level
In Module.xml
<module xmlns="urn:jboss:module:1.1" name="x1.x2">
<properties>
<property name="jboss.api" value="unsupported"/>
</properties>
<resources>
<resource-root path="ojdbc6-11.1.1.3.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
In domain.xml
<datasource jndi-name="java:/TestName" pool-name="TestName" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:#ldap://xxxxx:3000/UKXXX,cn=OracleContext,dc=dcm,dc=XXXX</connection-url>
<driver>dps</driver>
<security>
<user-name>XXXXX</user-name>
<password>*****</password>
</security>
</datasource>
<drivers>
<driver name="dps" module="x1.x2">
<xa-datasource-class>oracle.jdbc.driver.OracleDriver</xa-datasource-class>
</driver>
</driver>
</drivers>
Try to keep the correct ojdbc jar, some versions won't work :)
I want to set a mysql data source in jboss standalone mode. I have already deploy the mysql-connector-java-5.1.15-bin.jar and set the below data source configuration in standalone.xml under datasources
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/testdb</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
</security>
</datasource>
And when i click on the configured data source name in the web console im getting below error,
Internal server error{
"outcome" => "failed",
"failure-description" => "JBAS014739: No handler for read resource at address [
(\"subsystem\"=>"\datasource\"),
(\"data-source\"=>"\MySqlDS\"),
(\"statstics\"=>"\pool\"),
"],
"roleback" => "true"
}
I didnt add any thing to the drivers section since it not nessaccary,
Below one is set to the sample data source set in jboss
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class
</driver>
</drivers>
What i am missing here please?
You will also need to specify driver class
<driver-class>com.mysql.jdbc.Driver</driver-class>
Checkout this link How do I migrate my application from AS5 or AS6 to AS7
I've experienced the same issue under the same circumstances. The problem was that my AS didn't have the required module for PostgreSQL. Check in jboss/modules/org if you have a folder named postgresql. If not then create it. Then create a directory in it named main.
You then have to have two files present in there:
PostgreSQL JDBC JAR
module.xml configuration file
Download the JAR file according to the database you're using and copy it here. As for the module.xml just create a new file and set up the configuration. Mine looks like this, customize it for your case:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.3-1100.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Basically you just have to change the resource path to where your JAR file is.
This is an issue with JBOSS, it doesn't warn you even though the JDBC driver is missing. I've wasted a ton of time finding this hidden bug :D
I'm trying to create a datasource in JBOSS 7.
My standalone.xml excerpts:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="MySqlDS" pool-name="MySqlDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/sampledb</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>root</user-name>
<password>matrix</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>
and I have created module/com/mysql/main directory and have put mysql jar there along with module.xml which is as below:
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-3.0.17-ga-bin.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
and my persistence.xml uses this datasource
<jta-data-source>java:/MySqlDS</jta-data-source>
But the server start throws the error message as below.
New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing)
Could you please help ?
Thanks.
This will help you to fix the problem.
Jboss and mysql connector
See https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7/
Is the version of driver. Change for a new version. Believe, is only it!!!
I changed the driver mysql-connector-java-5.0.4-bin.jar for mysql-connector-java-5.1.25-bin.jar, then the problem is solved.
For me, after checking over and over that all of the module.xml and standalone.xml parameters where right. I realised i was using mysql-connector-java-xxx-bin.jar ...Changed it to a non bin jar and it MAGICALLY worked :D