-
15. Re: Jboss and mysql connector
vel_userid Feb 4, 2013 7:46 AM (in response to lukasw44)HI Guys
I'm using jboss-as-7.0.2.Final
I able to fix this problem, actually we need to give the name of driver declaration at the datasource definition,
see my contents below in standalone.xml
..........
<datasources>
<datasource jndi-name="java:/MySqlMktDataDS" pool-name="MySqlDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/vdb
</connection-url>
<driver>
mysql.Driver.Name
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
.......
</datasource>
.......
<drivers>
<driver name="mysql.Driver.Name" module="com.mysql">
<driver-class>
com.mysql.jdbc.Driver
</driver-class>
</driver>
</drivers>
</datasources>
* The remaining contents for module.xml and jar file location is same , my module.xml contents are below
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
-
16. Re: Jboss and mysql connector
matapurkar Feb 7, 2013 9:39 AM (in response to vel_userid)I was able to deploy my project with mysql-installer-community-5.5.29.0, mysql-connector-java-5.1.23 on jboss-as-7.1.1.Final. I made the following modifications:
Step 1. In jboss-as-7.1.1.Final\modules\com\mysql\main:
created module.xml:
<?xml version="1.0" encoding="windows-1252"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.23-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
And copied mysql-connector-java-5.1.23-bin.jar as well.
Step 2. In jboss-as-7.1.1.Final\standalone\configuration:
modified standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
...............
Add the following in <datasources>:
<datasource jta="true" jndi-name="java:/pmsDatasource1" pool-name="testdb" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/testdb</connection-url>
<driver>com.mysql.jdbc.Driver</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
And, under <drivers> add the following:
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
Step 3. In /*yourWorkspace*/*yourProject*/resources folder:
Modify pms-dev-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE datasources
PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
"http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource
jndi-name="java:/pmsDatasource"
enabled="true"
use-java-context="true" pool-name="testdb">
<connection-url>jdbc:mysql://localhost:3306/testdb</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
</datasources>
In /*yourWorkspace*/*yourProject*/resources/META-INF folder, modify persistence-dev.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="testdb">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/pmsDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/pmsEntityManagerFactory"/>
</properties>
</persistence-unit>
</persistence>
-
17. Re: Jboss and mysql connector
kjeldsen May 4, 2013 11:42 AM (in response to matapurkar)The steps provided by Vishal Matapurkar worked for me. However, instead of creating a -ds file, I used the persistence plugin in JBoss Forge to generate a persistence.xml file referencing the datasource in standalone.xml.
-
18. Re: Jboss and mysql connector
jwalin.pandya Jun 27, 2013 1:45 PM (in response to kjeldsen)This also works for RHQ 4.7 which has EAP 6.1 Alpha 1 (AS 7.2.0.Alpha1-redhat-4) .
-
19. Re: Jboss and mysql connector
jamesfrj Aug 21, 2013 9:33 PM (in response to lukasw44)I've tried the mysql datasource configuration on standalone-ha.xml and it was not detected when I restarted JBoss. Somebody knows why? What's the diference between configure on standalone.xml or standalone-ha.xml?