Friday 31 January 2014

Install JDBC driver in JBoss 7 Application Server


Class loading in JBoss AS7 is considerably different to previous versions of JBoss AS. Class loading is based on the JBoss Modules project. Instead of the more familiar hierarchical class loading environment, AS7's class loading is based on modules that have to define explicit dependencies on other modules. 

Lets install a MySql drive in JBoss 7 Application Server.


Step 1:

Create a folder structure (com/mysql/jdbc/main) under JBoss 7 modules folder and put   mysql connector jdbc driver jar file there: If you miss to create main folder then JBoss 7 won't recognize the driver so folder structure is also vital here.

Folder Structure: $jboss_home/modules/com/mysql/jdbc/main 


Step 2:

Create a xml file ( module.xml ) containing the following and put it under  $jboss_home/modules/com/mysql/jdbc/main.


<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
  <resources>
    <resource-root path="mysql-connector-java-5.1.24-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
  </dependencies>
</module>