jboss 7 oracle datasource configuration

74,220

Solution 1

Here's a link about the data source configuration for JBoss 7 that of course work with 7.1

https://community.jboss.org/wiki/DataSourceConfigurationInAS7

The example is configuring a MySQL example.
This is what i did for an Oracle Driver

<datasource jndi-name="java:/sigap_ws_receiver" pool-name="sigap_ws_receiver" enabled="true">
    <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=off)(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.1)(PORT=1524))(CONNECT_DATA=(SERVICE_NAME=profepa)(SERVER=DEDICATED)))</connection-url>
    <driver>com.oracle</driver>
    <pool>
        <min-pool-size>3</min-pool-size>
        <max-pool-size>5</max-pool-size>
    </pool>
    <security>
        <user-name>user</user-name>
        <password>pass</password>
    </security>
    <validation>
        <exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
    </validation>
    <timeout>
        <blocking-timeout-millis>5000</blocking-timeout-millis>
        <idle-timeout-minutes>5</idle-timeout-minutes>
    </timeout>
</datasource>

The driver's section would look like this:

<drivers>
    <driver name="com.oracle" module="com.oracle">
        <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    </driver>
</drivers>

My module.xml is under $JBOSS_HOME\modules\com\oracle\main within the jar ojdbc6.jar:

<module xmlns="urn:jboss:module:1.0" name="com.oracle">
    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>

Solution 2

All of these answers helped me to get it to works, but none of them was the exact solution so I thought I would add mine.

First, note that you can do this either in the JBoss web-console or by manually configuring the datasource in the xml files. However, I highly suggest that you configure it through the web-console to avoid error such as the one the OP made and that apparently no-one noticed :

<drivers>
  <driiver name="oracle" module="com.oracle.ojdbc6">
    <xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
  </driver>
</drivers>

Notice that the driver declaration contains two i.

Manual configuration [Not recommended]

First of all, you must make sure your Oracle jdbc is configured.

  • Navigate to $JBOSS_HOME/modules and if it does not already exists, create folder tree oracle/jdbc/main.
  • Navigate to that folder and copy the odjbc6-11.jar.
  • Create module.xml with the following content
<module>
    <resources>
        <!-- make sure the path match the name of the file -->
        <resource-root path="ojdbc6-11.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

Now that your jdbc is configured, you must edit the standalone.xml file to specify the driver and datasource properties.

  • Navigate to $JBOSS_HOME/standalone/configuration and edit standalone.xml file.
  • Locate the drivers tag and configure your driver as follow :
<driver name="oracle" module="oracle.jdbc">
    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
  • Now add the datasource configuration :
<datasource jndi-name="java:jboss/datasources/Altis" pool-name="Altis" enabled="true">
  <connection-url>jdbc:oracle:thin:@255.255.255.255:1521:sid</connection-url>
  <driver-class>oracle.jdbc.OracleDriver</driver-class>
  <driver>oracle</driver>
  <security>
    <user-name>username</user-name>
    <password>passwd</password>
  </security>
</datasource>

Online configuration [Recommended]

  • Navigate to the management console (by default localhost:9990/console)
  • Click on Configuration and expand Datasources in Connector
  • Click on add (first button on right of the datasources table)
  • Fill in the Name, in your case Altis
  • Fill in the JNDI name, in your case java:jboss/datasources/Altis. Note that JNDI name has to start with java:/ or java:jboss/
  • Select your driver, it should be in the detected driver if it was properly configured.
  • Fill in the connection url as jdbc:oracle:thin:@255.255.255.255:1521:sid
  • Fill in the username and password.
  • You can left empty the security domain if you want or specify one.
  • Make sure you test the connection before clicking on Done.
  • Once the datasource is saved, select it in the table and click on Enable

Solution 3

In the module.xml jar, you have path="ojdbc6.jar" for the resource-root tag, but you said you downloaded ojdbc6-11.jar

I think you need to have path="ojdbc6-11.jar" in your module.xml

Share:
74,220
user1066568
Author by

user1066568

Updated on July 14, 2022

Comments

  • user1066568
    user1066568 almost 2 years

    I'm currently migrating from jboss 4.3 to jboss 7.1.1 (Final) and i'm trying to configure an oracle datasource but it's not working. Following is what I've done to setup an oracle datasource

    1)Downloaded ojdbc6-11.jar and placed it inside the folder $JBOSS_HOME/modules/com/oracle/ojdbc6/main

    2)Created the file module.xml under $JBOSS_HOME/modules/com/oracle/ojdbc6/main and this is the content of the file

    <module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6">
      <resources>
        <resource-root path="ojdbc6.jar"/>
      </resources>
      <dependencies>
        <module name="javax.api"/>
      </dependencies>
    </module>
    

    3)Added the following driver and datasource inside standalone.xml

    <drivers>
      <driiver name="oracle" module="com.oracle.ojdbc6">
        <xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
      </driver>
    </drivers>
    
    <datasource jndi-name="java:/Altis" pool-name="Altis" enabled="true" use-java-context="true">
      <connection-url>connurl</connection-url>
      <driver>oracle</driver>
      <security>
        <user-name>username</user-name>
        <password>passwd</password>
      </security>
    </datasource>
    </datasources>
    

    However, when I deploy my war file, i get the following error

    16:54:43,281 INFO  [org.jboss.as.server] (HttpManagementService-threads - 2) JBA
    S015870: Deploy of deployment "altisavante.war" was rolled back with failure mes
    sage {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.na
    ming.context.java.module.altisavante.altisavante.env.Altisjboss.naming.context.j
    ava.AltisMissing[jboss.naming.context.java.module.altisavante.altisavante.env.Al
    tisjboss.naming.context.java.Altis]"]}
    

    Am I missing anything?