Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBoss Datsource Issue

 
Anu Wadhwa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to deploy multiple enterprise applications on JBoss which define their own datasource with the same jndi-name jdbc/appSM. I defined the datasource as follows in one of the EAR

I have oracle-ds.xml in my app.ear/META-INF.
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/appSM</jndi-name>
<connection-url>jdbcracle:thin:@wer:1521:hh760</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>op$app</user-name>
<password>app</password>
<exception-sorter-class-
name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</data

jboss-web.xml in webgui.war/WEB-INF dir
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/appSM</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/jdbc/appSM</jndi-name>
</resource-ref>
</jboss-web>

In WEB-INF/web.xml,
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/appSM</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>

The above works fine. Now if I try to use the same jndi-name again in another EAR I get an error that the resource is already bound. Can anyone tell me how can I make a datasource local to the application? Basically I want the datasource to be visible only within the Enterprise app.

Thanks !!
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jndi-name of the datasource is always global and hence has to be unique within a server. You won't be able to deploy 2 datasources with the same jndi name on the same server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic