Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to Resolve this exception in tomcat 5.0.28

Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

How to resolve the below exception in tomcat 5.0.28.

"javax.naming.NameNotFoundException: Name java:comp is not bound in this Context "

Here is my code:

<%@page contentType="text/html"%>
<%@ page import="javax.naming.*"%>
<%@page import="java.sql.*" %>
<%@page import="javax.sql.*" %>

Connection con=null;
try {

Context init = new InitialContext();
Context ctx = (Context) init.lookup("java:comp/env");
DataSource datasource = (DataSource) ctx.lookup("jdbc/j1");

try {
con = datasource.getConnection();
}catch(Exception e)
out.print("Cannot retrievesss connection:"+e.toString()); return;

catch(Exception ex) {

Thanks in Advance.
I am displeased. You are no longer allowed to read this tiny ad:
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic