users@glassfish.java.net

Re: Newbie question - is it possible to deploy 2 contexts using same war file

From: <glassfish_at_javadesktop.org>
Date: Sat, 20 Feb 2010 22:21:04 PST

You can use "resource-ref" in web.xml and sun-web.xml to map a "jdbc-resource" with a specific jndi-name (physical-name) to logical-name that can be looked up by the web component.

eg:

web.xml

<resource-ref>
        <res-ref-name>DataSource2</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>


sun-web.xml
  <resource-ref>
        <res-ref-name>DataSource2</res-ref-name>
        <jndi-name>jdbc/my-ds</jndi-name>
      </resource-ref>


So, the jdbc-resource with jndi-name "jdbc/my-ds" is mapped to logical namespace "java:comp/env/DataSource2" for the web-component via the "resource-ref" in web.xml and sun-web.xml.
[Message sent by forum member 'jr158900' (Jagadish.Ramu_at_Sun.com)]

http://forums.java.net/jive/thread.jspa?messageID=387817