Curtis Garman wrote:
I've only every declared in in META-INF/context.xml
It's fine to define Resource completely in context.xml.
But if one uses GlobalNamingResources (as OP does) he has to declare mapping in context.xml as I described.
Anyway, it works for me all the times :-)

Of course, in Java code one has to lookup using full path, not just "mail/Session", so:

new InitialContext().lookup("java:comp/env/mail/Session");

So, I have on my Tomcat 6.0:

conf/server.xml:

<GlobalNamingResources>
             <Resource name="jdbc/db" auth="Container"
               type="javax.sql.DataSource"
               driverClassName="org.postgresql.Driver"
               ...
               />

application's META-INF/context.xml:

<Context>
       <ResourceLink name="jdbc/db"
           global="jdbc/db"
           type="javax.sql.DataSource" />
</Context>

application's WEB-INF/web.xml:

       <resource-ref>
               <res-ref-name>jdbc/db</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <res-auth>Container</res-auth>
       </resource-ref>


And I use new InitialContext().lookup("java:comp/env/jdbc/db"); to retrieve DataSource.

Hope that helps.

--
Mikolaj Rydzewski <m...@ceti.pl>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to