[jboss-user] [Beginner's Corner] - Datasource specification in web.xml

Jan Vrtiska do-not-reply at jboss.com
Thu Nov 17 04:01:01 EST 2011


Jan Vrtiska [http://community.jboss.org/people/xjohnx] created the discussion

"Datasource specification in web.xml"

To view the discussion, visit: http://community.jboss.org/message/636933#636933

--------------------------------------------------------------
Hi,
I have my project application which has been connecting to one simple datasource(which was defined in jbos-web.xml). Now I need to build form my application two *.war files and each of them will use different datasource. Since Im using ant, I can change in my build.xml file destination of web.xml file. So I have two web.xml files with different datasource deffinitions.
The problem is, that my solition is not working. After triing to reach my appplication i get error:

*javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]*

 web.xml
<resource-ref> 
 <res-ref-name>DataSource</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <mapped-name>DataSource</mapped-name>
</resource-ref>


 adpartner-ds.xml
<local-tx-datasource>
    <jndi-name>DataSource</jndi-name>     
.....


java code:
InitialContext ctx = null;
 try {
 ctx = new InitialContext();
 
 dataSource = (DataSource) ctx.lookup("java:comp/env/DataSource");
 LOG.info("lookup na datasource");
 } catch (NamingException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
 }
 this.daoFactory = new DaoFactory(this.dataSource);
 


I've tried to search solution on web but without any success.
Thanks for any help.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/636933#636933]

Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111117/20ac39c8/attachment.html 


More information about the jboss-user mailing list