Name jdbc is not bound in this Context
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dheeraj_Bhardwaj
Posted On:   Thursday, January 13, 2005 12:44 PM

Hi, I am using tomcat 5.5.4 and mysql. my server.xml file is as follows: <?xml version='1.0' encoding='utf-8'?> my ROOT.xml file is as follows: <?xml version='1.0' encoding='utf-8'?> The call for connection code is follows: public Connection establishCtxConnection() throws Exception { Connection conn=null; try    More>>

Hi,



I am using tomcat 5.5.4 and mysql. my server.xml file is as follows:



<?xml version='1.0' encoding='utf-8'?>











































my ROOT.xml file is as follows:



<?xml version='1.0' encoding='utf-8'?>







The call for connection code is follows:



public Connection establishCtxConnection() throws Exception

{

Connection conn=null;

try

{

Context initContext = new InitialContext();

Context envContext = (Context)initContext.lookup("java:comp/env");

DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");

conn = ds.getConnection();
}


catch( Exception e ){ System.out.println("error getting DB connection " + e.getMessage() );

e.printStackTrace();

}

return conn;

}



It throws the following error:


javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

at org.apache.naming.NamingContext.lookup(NamingContext.java:769)

at org.apache.naming.NamingContext.lookup(NamingContext.java:152)

at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(ResourceLinkFac tory.java:96)

at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)

at org.apache.naming.NamingContext.lookup(NamingContext.java:792)

at org.apache.naming.NamingContext.lookup(NamingContext.java:139)

at org.apache.naming.NamingContext.lookup(NamingContext.java:780)

at org.apache.naming.NamingContext.lookup(NamingContext.java:152)

at labeaumonde.amityzoneweb.establishCtxConnection(amityzoneweb.java:239)

at labeaumonde.amityzoneweb.getRecord(amityzoneweb.java:2442)

at org.apache.jsp.memberlogin_jsp._jspService(org.apache.jsp.memberlogin_jsp:99)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil terChain.java:237)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 214)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10 7)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnecti on(Http11Protocol.java:731)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:5 26)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorke rThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:6 84)

at java.lang.Thread.run(Unknown Source)



Can someone please point out what the problem could be?



Thanks
Dheeraj

   <<Less

Re: Name jdbc is not bound in this Context

Posted By:   Anonymous  
Posted On:   Tuesday, January 18, 2005 08:57 AM

look here, had same prob, now it works


http://forum.java.sun.com/thread.jspa?threadID=563682&messageID=2775875

Re: Name jdbc is not bound in this Context

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, January 15, 2005 08:01 AM

Not sure in Tomcat (this stuff differs among containers) but have you tried just looking up "jdbc/Test" from your initial context, without the intervening "java:comp/env" lookup?
About | Sitemap | Contact