Sunday, January 2, 2011

JBOSS AS 6 : Adding and testing a new Oracle 11g datasource

1 Prerequisites
  • Oracle 11g (R1 or R2 doesn't matter but anyway, I installed the R1)
  • a defined database
  • JBoss AS 6
 2 Adding the new datasource

As described in the JBoss AS documentation, we just need to create and configure a new RDBS-ds.xml file and put it in the jboss-6.0.0.Final\server\your-server-configuration\deploy directory.

In my case, in order to get to the point as quickly as possible (and because I only need a basic datasource configuration at the moment), I created my own oracle-ds.xml file by copying the sample one which is located at : jboss-6.0.0.Final\docs\examples\jca

Here's my own oracle-ds.xml file :

<?xml version="1.0" encoding="UTF-8"?>

At this point there's 2 things you should pay attention to :
  • Make sure there's no other xxx-ds.xml file with an identical jndi-name, otherwise, the datasource cannot be deployed correctly.
  • Don't forget to drop the appropriate JDBC driver library in the same directory as the datasource configuration file, that is : jboss-6.0.0.Final\server\your-server-configuration\deploy
3 Testing the connection
1° start the application server
2° log into the server administration console (http://localhost:xxxx/admin-console/login.seam)
3° go to the datasource section as shown below

4° Select the newly created datasource and open the CONTROL tab

5° Click on the Test connection button to run a test
6° As as result, make sure the test ran successfully and that a connection has been obtained

    To check whether a connection has been obtained, especially if you ran several tests, click on the Show 
    details below... button and make sure the result value is Yes

    The result value is critical to test the connection to your datasource because as long as your datasource 
    configuration file is correct, the test could run successfully while your database is not even running, for 
    instance ...


  1. I've done exactly the same thing against an Oracle database. I get the 'success' value in the result but my console running JBoss shows the errors below. Any idea why? Is this really a problem and if so do I need to update some other config file?

    16:03:36,937 ERROR [] Failed to
    load users/passwords/role files: No properties file: users
    .properties or defaults: found
    at [:3.0.

  2. I've never really paid attention to the log till now but it turns out that I am getting the exact same error when testing my datasource connection.

    I don't have any clue so far why this message shows up but I definitely will investigate this issue and let you know if I find anything.

    Did you happen to try the same thing on a previous release of JBoss ?

  3. Thanks for checking. Honestly this is the first time I tried it. I'm just familiarizing myself with JBoss now so I'm not sure about previous versions. Even with the message in the log, when I use the connection pool it seems to be working fine. I can can get a connection and make calls against the database. I guess log message is something not to worry about ;-)

  4. Hi there,

    I'm pretty sure the following link would help you (as well as myself, actually) understand and resolve the error message you've described :

    The personal project I am working on does not need login module yet but as soon as I get to this necessity, I will definitely write a post about that

    Kind regards

  5. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.