JDBC Datasource on JBoss

Unofficial Content

¿How to setup a JDBC datasource on Jboss to use it's connection pool, instead of using GeneXus' connection pool?

To define the datasource, this is an excellent guide to follow:

http://www.onjava.com/pub/a/onjava/2004/02/25/jbossjdbc.html

Exclusively for Oracle:
http://www.onjava.com/pub/a/onjava/2004/02/25/jbossjdbc.html#oracle

 


JBoss 4.0:

For instance, use JDBC driver type 4 (classes12.jar which is available in oracle site, for oracle 10g)

Then just follow this steps:
1. Install the application in server/default/deploy, and at server/default/lib put the JDBC Driver.
2. Copy /docs/examples/jca/oracle-ds.xml to /server/default/deploy/
3. Edit oracle-ds.xml file and change <driver-class/> and <connection-url/> tags.
4. At server\default\conf edit standardjaws.xml and change <datasource> and <type-mapping> tags.
5. At server\default\conf edit standardjbosscmp-jdbc.xml file and change <datasource> and <datasource-mapping> tags.

NOTE:According to some test performed by Artech, steps 4 and 5 can be omitted.
At Use Datasource for Web based applications = true and in JDBC Datasource model property you must enter: java:/OracleDS

 

JBoss 6.0:

Example for Oracle 10g

1. Repeat both steps 2 and 3 from previous case.

2. Create a file called jboss-web.xml at WEB-INF Directory with this structure in it:

<!DOCTYPE jboss-web PUBLIC
   "-//JBoss//DTD Web Application 5.0//EN"
   "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
   <resource-ref>
       <res-ref-name>jdbc/OracleDS</res-ref-name>
       <jndi-name>java:/OracleDS</jndi-name>
   </resource-ref>
</jboss-web>
 
Where jndi-name = "java:/" concatenated with jndi-name defined in oracle-ds.xml.
 

3. Edit web.xml file adding:

<resource-ref>  
    <res-ref-name>jdbc/OracleDS</res-ref-name>  
    <res-type>javax.sql.DataSource</res-type>  
    <res-auth>Container</res-auth>  
</resource-ref>
 
Where res-ref-type has the same value defined in jboss-web.xml
 
Note: As for GeneXus 15 up to GeneXus 16 Upgrade 5 and lower, everytime it was configured at the database level to Use datasource for web based applications, when using the deployment tool, this entry will be automatically added.
As for GeneXus 16 Upgrade 6 and higher, this changed, please check SAC#46064.
 

4. Generate war file and install the application on server/default/deploy and copy ojdbc14.jar driver in server/default/lib.