Home » Developer & Programmer » JDeveloper, Java & XML » see my error :::=>>> javax.servlet.ServletException: Name myoracle is not bound in this Con
see my error :::=>>> javax.servlet.ServletException: Name myoracle is not bound in this Con [message #218942] Mon, 12 February 2007 03:18
mfa786
Messages: 210
Registered: February 2006
Location: karachi
Senior Member
hi master

sir i am use oracle 9i jsp with tomcat server

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" />
</GlobalNamingResources>
- <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="jdbc:oracle:thin:@127.0.0.1:1521:aamir" username="muhammad" password="mfa786" maxActive="20" maxIdle="10" maxWait="-1" />

</Context>
</Host>
</Engine>
</Service>
</Server>
==
this my web.xml

=======
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>

=====

this is my jsp code

===

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<%@ 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(); %>

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

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


</body>
</html>

==

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

thank
Previous Topic: how use one orecla 9i recoreset to other jsp netbeans 5.5 page
Next Topic: JDeveloper 9.0.4.0.1407 Error
Goto Forum:
  


Current Time: Tue Dec 03 18:08:19 CST 2024