Sunday, October 6, 2013

How to deploy jdbc driver as a module in JBoss AS7

When multiple applications are using the same jdbc driver in an JBoss AS7, it is good to deploy the jdbc driver as a module instead of deploying the jdbc driver in every applications.

or we need to create JNDI datasource connection in JBoss AS7, then it is a must to deploy the jdbc driver into JBoss AS7, else JBoss AS7 is unable to create database connection to the target DB.

Steps:
1. create folder in <JBoss_AS7_installation_folder>/modules
    eg, oracle

2. put the ojdbc14.jar (the oracle jdbc driver) in the main folder

3. create module.xml in main with the following content
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.ojdbc14">
    <resources>
        <resource-root path="ojdbc14.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

4. create jdbc driver entry in standalone.xml
    a) open <JBoss_AS7_installation_folder>/standalone/configuration/standalone.xml
    b) search for <drivers>
    c) add the following content between <drivers>...</drivers>
<driver name="oracle" module="com.oracle.ojdbc14">
 <xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>

5. start JBoss AS7
    if ojdbc14.jar.index generated in <JBoss_AS7_installation_folder>/modules/com/oracle/ojdbc14/main,
    that's mean the oracle jdbc driver is successfully deployed as a module in JBoss AS7.

Optional
6. Create JNDI datasource in JBoss AS7.


Done!!

2 comments:

  1. I couldnt find the oracle driver
    Only h2 is available when I tried to
    Create data source
    Thank you

    ReplyDelete
    Replies
    1. Please checkhttp://www.kianworknotes.com/2013/10/how-to-deploy-jdbc-driver-as-module-in.html to add driver to jboss

      Delete

LinkWithin

Related Posts Plugin for WordPress, Blogger...