problem configure JBoss to work with JNDI

Posted by Spiderman on Stack Overflow See other posts from Stack Overflow or by Spiderman
Published on 2010-05-13T15:53:38Z Indexed on 2010/05/14 11:24 UTC
Read the original article Hit count: 321

Filed under:
|
|

I am trying to bind connection to the DB using JNDI in my application that runs on JBoss. I did the following:

  1. I created the datasource file oracle-ds.xml filled it with the relevant xml elements:
<datasources>
   <local-tx-datasource>
     <jndi-name>bilby</jndi-name>
     ...
    </local-tx-datasource>
</datasources>

and put it in the folder \server\default\deploy

  1. Added the relevant oracle jar file

  2. than in my application I performed:

JndiObjectFactoryBean factory = new JndiObjectFactoryBean();

 factory.setJndiName("bilby");
 try{
     factory.afterPropertiesSet();
     dataSource = factory.getObject();
 }
 catch(NamingException ne) {
     ne.printStackTrace();
 }

and this cause the error:

javax.naming.NameNotFoundException: bilby not bound

then in the output after this error occured I saw the line:

18:37:56,560 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb oss.jca:service=DataSourceBinding,name=bilby' to JNDI name 'java:bilby'

So what is my configuration problem? I think that it may be that JBoss first loads and runs the .war file of my application and only then it loads the oracle-ds.xml that contain my data-source definition. The problem is that they are both located in the same folder. Is there a way to define priority of loading them, or maybe this is not the problem at all.

Any idea?

© Stack Overflow or respective owner

Related posts about java

Related posts about jndi