aspose file tools*
The moose likes Tomcat and the fly likes exception - name jdbc is not bound in this context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "exception - name jdbc is not bound in this context" Watch "exception - name jdbc is not bound in this context" New topic
Author

exception - name jdbc is not bound in this context

Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
Dear friends,

I am using tomcat 6.0.29 and trying to configure JNDI
I have made Advocate.war file from my web application Directory whose structure is as under:-
Advocate - It contains two directories viz. WEB-INF and META-INF
In the WEB-INF directory there is web.xml file and a directory called classes. In the classes directory there is a directory called MyPackage and in the MyPackage directory there is loginDAO.class file.

The code for web.xml is as under:-


In the META-INF directory there are files MANIFEST.MF and context.xml. The code for context.xml is as under:-


And the Code for loginDAO.java (the class which is throwing exception is)



However when I invoke the class through a JSP it gives the following error:-

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

javax.servlet.ServletException: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.log_jsp._jspService(log_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.naming.NamingContext.lookup(NamingContext.java:770)
org.apache.naming.NamingContext.lookup(NamingContext.java:153)
MyPackage.loginDAO.<init>(loginDAO.java:19)
org.apache.jsp.log_jsp._jspService(log_jsp.java:57)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

I have also tried

as well as


But still it gives he same error. However, I have not made any changes to server.xml file.
Please help.

Anand Shrivastava
SCJA
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21



Should be OK. Your context looks OK. My best guess is that you've been hit by one of Tomcat's more annoying features. If you replaced the WAR file but didn't delete the exploded WAR, the exploded WAR is what will be used, even if the exploded WAR is older than the WAR file. So you may be using a WAR with a META-INF/context.xml that doesn't have the proper connection pool configuration.

Always delete exploded WARs when deploying new versions.


Customer surveys are for companies who didn't pay proper attention to begin with.
Anand Shrivastava
Ranch Hand

Joined: Jul 22, 2007
Posts: 125
Yes, you were right. Thanks a lot for fixing it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception - name jdbc is not bound in this context