Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm having some problems with tomcat 7 for configuring jdbc-pool : i`ve tried to follow this example:

so i have:


  <Resource type="javax.sql.DataSource"


  <ResourceLink type="javax.sql.DataSource"

and when i try to do this:

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource datasource = (DataSource)envContext.lookup("jdbc/LocalDB");
Connection con = datasource.getConnection();

i keep getting this error:

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
 at org.apache.naming.NamingContext.lookup(
 at org.apache.naming.NamingContext.lookup(

pls help tnx

share|improve this question

Check your context.xml file. Did you embed the <Context> within the existing <Context> of the default file?

Worst case scenario it to take this:

  <ResourceLink type="javax.sql.DataSource"

...and ensure it is within the already existing <Context> tag and get rid of the extraneous ones.

In general, I never recommend editing the server.xml or context.xml for the purpose of creating these resources. The Tomcat documentation will back me up on that to some extent:

See the tail end of the Introduction section. Typically I create context.xml.default files or even appname.xml files in the /conf/Catalina/localhost directory for such purposes. Abstracts the global configuration from the application specific configuration.

share|improve this answer

Typically I create context.xml.default files or even appname.xml files in the /conf/Catalina/localhost directory for such purposes.

It's the right way.

share|improve this answer

You can do the lookup in one line via java:comp/env/jdbc/DB, you don't need two lookups.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.