• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception - name jdbc is not bound in this context

 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you were right. Thanks a lot for fixing it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic