Installing Oracle JDBC-Driver On Wildfly / JBoss

  1. Download the driver: ojdbc[VERSION].jar
  2. Create subfolders [WILDFLY_HOME]/modules/system/layers/base/com/oracle/main/
  3. Copy the downloaded ojdbc[VERSION].jar into the freshly created folder
  4. Create a file module.xml, in the same folder as above, with the contents:
    
    <module xmlns="urn:jboss:module:1.1" name="com.oracle">
      <resources>
        <resource-root path="ojdbc[VERSION].jar"/>
      </resources>
      <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
      </dependencies>
    </module>
    
    
  5. In the configuration file standalone.xml add the entry:
    
    <driver name="oracle" module="com.oracle">
     <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    </driver>
    
    
    within the <drivers> tag.
  6. Add a datasource definition within the <datasources> tag (next to ExampleDS):
    
    <datasource jndi-name="java:/[NAME]" pool-name="OracleDS" enabled="true">
     <connection-url>jdbc:oracle:thin:@[HOST_NAME]:1521:[SID]</connection-url>
      <driver>oracle[has to match the driver name]</driver>
      <pool>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>5</max-pool-size>
       <prefill>true</prefill>
      </pool>
      <security>
       <user-name>[USER]</user-name>
       <password>[PWD]</password>
      </security>
    </datasource>
    
    

Now enjoy the simplicity of Java EE :-)

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

Hi Adam,

Could be done through scripting as well as discussed in the workshop :)

#To create the module (not part of the batch)
module add --name=com.oracle --resources=[path-to-driver]/ojdbc6.jar --dependencies=javax.api,javax.transaction.api

batch

/subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle,driver-module-name=com.oracle,driver-xa-datasource-class-name=oracle.jdbc.driver.OracleDriver)

/subsystem=datasources/data-source="[NAME]":add(jta="true",use-ccm="true",use-java-context="true",enabled="true",jndi-name=java:/jdbc/[NAME],max-pool-size=10,min-pool-size=5,flush-strategy="FailingConnectionOnly",driver-name=oracle,connection-url=jdbc:oracle:thin:@[HOST_NAME]:1521:[SID],user-name="[user]",password="[password]")

run-batch

Posted by jean-noel on March 26, 2015 at 07:06 PM CET #

Hi Adam,

why ojdbc6.jar and no ojdbc7.jar?
Thank you for this blog.

Kai

Posted by Kai on March 26, 2015 at 10:08 PM CET #

oracle.jdbc.OracleDriver have to be used since Oracle 9i !

oracle.jdbc.driver.OracleDriver is deprecated and causes problems in some circumstances.

Posted by Karsten on March 27, 2015 at 07:38 AM CET #

Hi Adam,

it can be done via jboss-cli.

https://gist.github.com/pehunka/5d0eb97b23168a65bdb7

I'm having the whole development box with automation of postgres and oracle dbs as well as jdks and few appservers. I can open-sourced, if somebody will be interested :-)

Cheers,
Petr

Posted by Petr on March 27, 2015 at 09:48 AM CET #

My memory isn't really a thing but can't you just add it via the admin console? I guess it gets automatically detected as a JDBC driver and you can just setup the connection via the UI as well

Posted by Solerman Kaplon on April 01, 2015 at 04:23 PM CEST #

Hi Adam,

to adhere to wildfly's common module conventions i would propose "oracle.jdbc" as module name instead of "com.oracle" since this is the package prefix of the classes within the jar.
The module's folder would thus of course be: oracle/jdbc/main/

Just to be sure ;-)
Bye!

Posted by Heli on May 18, 2015 at 09:35 PM CEST #

The base folder for 3rd party modules isn't [WILDFLY_HOME]/modules/system/layers/base. It's just [WILDFLY_HOME]/modules/. Then you immediately continue with e.g. com/oracle/main/

Posted by Juergen Zimmermann on June 05, 2015 at 06:04 AM CEST #

what do you need to do if the database you want to connect to requires you to connect to it via ssl? I have the proper certs and they are already in the a keystore since I've set this up in glassfish before, but I cant find anything about what I need to do to make this happen with wildfly

Posted by brett on June 18, 2015 at 03:53 AM CEST #

Hi Admin,

How to Add Datasource from web ?

Any Idea ? If so, can you post here or send by to my mail.

Thank you.
Rajkumar Samala

Posted by Rajkumar Samala on July 14, 2015 at 09:11 AM CEST #

Thank you!

Posted by Anderson David de Souza on February 29, 2016 at 05:49 PM CET #

Hi, I have downloaded ojdbc7.jar
make the same as described above but get error:

09:58:19,416 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "OracleDS")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.ojdbc7_jar]",
"jboss.driver-demander.java:/jdbc/VZAJEMNAPRODDS is missing [jboss.jdbc-driver.ojdbc7_jar]"
]}
09:58:19,422 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "OracleDS")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.ojdbc7_jar]",
"jboss.driver-demander.java:/jdbc/VZAJEMNAPRODDS is missing [jboss.jdbc-driver.ojdbc7_jar]",
"org.wildfly.data-source.OracleDS is missing [jboss.jdbc-driver.ojdbc7_jar]"
]}
09:58:19,485 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.ojdbc7_jar (missing) dependents: [service jboss.driver-demander.java:/jdbc/VZAJEMNAPRODDS, service org.wildfly.data-source.OracleDS]

thank you for any info..

Posted by Peter on June 02, 2016 at 09:58 AM CEST #

There is an error on this tutorial.

Here the correct lines on standalone.xml or standalone-full.xml

You need to add .jdbc on the module so com.oracle.jdbc

driver name="oracle" module="com.oracle.jdbc"

Posted by Gauthier on August 22, 2016 at 06:36 PM CEST #

I just hate how it so much complex to do such a simple thing. Why not just drop the library (and all its dependencies if there are some) in a /common/lib directory and basta?!

D.

Posted by Daniel W. on October 12, 2016 at 01:58 PM CEST #

Thank you for this guideline, it helped me a lot!

Posted by Carlos on November 09, 2016 at 09:54 AM CET #

It's not normally necessary to install JDBC drivers as modules. The JDBC driver jar can be deployed as a jar using the CLI or by simply copying it into the "deployments" directory.

Possible reasons for using a module definition instead include:

a) the driver is dependent upon other jars;

b) your server hosts multiple applications that are dependent upon different versions of the same vendor's driver

Posted by Steve Coy on November 28, 2016 at 12:21 PM CET #

Good post.Thank you very much.

Posted by Shalika on May 05, 2017 at 06:43 AM CEST #

It worked in Wildfly 11 as well. Thanks

Posted by Lorenzo on December 13, 2017 at 03:15 PM CET #

The guys who design this has to be on drugs. I never saw something complex and unpredictable like Java EE. There is little change in every version and you basically don't code anymore, you configure and looking in manuals, what magic which property does...grrr

Posted by Martin on January 08, 2018 at 03:03 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License