Digital Marketing

How to install JDBC driver to JBoss EAP 6 / WildFly 8

On JBoss EAP 6 / WildFly 8, you have two ways of installing the JDBC driver:
  1. deploy it as any other application package
  2. install it as a module
Deploy the driver as application package is recommend when you have a cluster environment, since the deployments are automatically propagated in the server groups.

See also:

How to add Datasource to JBoss EAP 6 / WildFly 8

Deploying the JDBC Driver

When the JDBC driver is installed as a deployment, it is deployed as a regular JAR. If the JBoss EAP 6 / Wildfly instance is running as a standalone server, copy the JDBC 4.0 compliant JAR into the Application_server_HOME/standalone/deployments/ directory. For a managed domain, you must use the Management Console or Management CLI to deploy the JAR to the server groups.

The following is an example of a MySQL JDBC driver installed as a deployment to a standalone server:

$cp mysql-connector-java-5.1.33-bin.jar Application_server_HOME/standalone/deployments/

You can deploy from the admin console too. Go to Runtime > Server > Manage Deployments and click on Add to deploy the JDBC driver. Upload the driver and give a new name to it. Any JDBC4-compliant driver is automatically recognised by WildFly and made available for new datasources. If not using a JDBC4 driver, then click on En/Disable right after the deployment.

Creating a Module

You may have issues with the deployment if the driver is not JDBC4-compliant. In this case, installing the driver as a module solves those issues. The advantage of the JDBC driver as a module is the possibility of creating a custom WildFly bundle for your organization. This way, you can repeat exactly the same installation throughout several machines, preserving the same configuration. This is perfect for the development environment.

To create a module (use MySQL as example):
  1. Unzip the downloaded file and copy the file mysql-connector-java-5.1.33-bin.jar to the new folder (create the subfolder as needed) WILDFLY_HOME/modules/system/layers/base/com/mysql/main
  2. create the file module.xml in the same folder with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
       <module xmlns="urn:jboss:module:1.1" name="com.mysql">
               <resource-root path="mysql-connector-java-5.1.33-bin.jar"/>
               <module name="javax.api"/>
               <module name="javax.transaction.api"/>
The name of the driver file may vary, so make sure you declare exactly the same name in the resource-root tag. At this point, the module is not available yet. We still need to reference the module as a driver in WildFly configuration. Do it using the following command:
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(
The command returns {"outcome" => "success"} in case of success. This command resulted in the following part in the configuration file:
           <driver name="mysql" module="com.mysql">
It makes the JDBC driver module available for the datasource creation.


Popular posts from this blog

Make online money from the Internet