Get your CodeRanch badge!*
The moose likes Other Java Products and Servers and the fly likes JNDI on startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "JNDI on startup" Watch "JNDI on startup" New topic
Author

JNDI on startup

karthik kesan
Greenhorn

Joined: May 09, 2006
Posts: 1
I need to load my JNDI datasource before the startup servlet,becacuse in startupservlet I am having some code which loads some values from the database.

I am using the lookup code to get the JNDI name ,but it is not finding that name.


web.xml code added this code after taglibs definitions
<resource-ref>
<description>Primary database</description>
<res-ref-name>jdbc/wbol</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

sun-web.xml code
<resource-ref>
<res-ref-name>jdbc/wbol</res-ref-name>
<jndi-name>jdbc/wbol</jndi-name>
</resource-ref>

java code:
initContext = new InitialContext();
source = (DataSource) initContext.lookup ("java:comp/env/jdbc/wbol");

can anyone help me out to resolve this issue.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
You need to configure the JNDI Data Source in the Admin application for the server.
http://docs.sun.com/source/819-0076/jdbc.html


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JNDI on startup
 
Similar Threads
JNDI datasource lookup problem
Warning: Resource reference is not defined for JNDI name
JNDI DataSource lookup problem
JBOSS connection pooling
DataSource is Null in JNDI Connection with Tomcat