File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes javax. servlet. ServletException: Name myoracle 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "javax. servlet. ServletException: Name myoracle is not bound in this Context  " Watch "javax. servlet. ServletException: Name myoracle is not bound in this Context  " New topic

javax. servlet. ServletException: Name myoracle is not bound in this Context

muhammad fahim
Ranch Hand

Joined: Dec 17, 2006
Posts: 45
hi master

sir i am use oracle 9i jsp with tomcat server (under netbeans 5.5)

this is my server.xml file

- <Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener" />
- <GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30" />
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
- <Service name="Catalina">
<Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
- <Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
- <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

- <Context path="/WebApplication7" docBase="WebApplication7" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbcracle:thin:@" username="muhammad" password="mfa786" maxActive="20" maxIdle="10" maxWait="-1" />

this my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<servlet-name>Faces Servlet</servlet-name>
<servlet-name>Faces Servlet</servlet-name>
<description>Oracle Datasource example</description>


this is my jsp code


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<%@ page import="java.sql.*,java.util.*" %>
<%@ page import="javax.sql.DataSource" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext"%>

<% Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection(); %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>

<h1>JSP Page</h1>
JavaServer Faces Welcome Page



sir this line give me error

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

this error
javax.servlet.ServletException: Name myoracle is not bound in this Context

please give me idea how i shove this error and show my data in jsp page

Kaustabh Singha Roy
Ranch Hand

Joined: Oct 04, 2005
Posts: 43
Where you have placed the JDBC Driver jar file? If they are at tomcat common/lib then this kind of problem may happen. Try to put a copy of the driver jar file and commons-dbcp.jar file at WEB-INF/lib of your application. Hope this will help.
I agree. Here's the link:
subject: javax. servlet. ServletException: Name myoracle is not bound in this Context
It's not a secret anymore!