-
JNDI NamingException
Hi,
I'm trying to connect to an SQL Server database using JNDI lookup from Tomcat 5.5.9 and eclipse 3.1 and got an exception I can't figure out.
The error message reads: Name BookDb is not bound in this Context
I use "http://localhost:8080/admin" to config Data Source
My server.xml looks like:
...
<GlobalNamingResources>
<GlobalNamingResources>
<Environment
name="simpleValue"
type="java.lang.Integer"
value="30"/>
<Resource
auth="Container"
description="User database that can be updated and saved"
name="UserDatabase"
type="org.apache.catalina.UserDatabase"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource
name="jdbc/BookDB"
type="javax.sql.DataSource"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
password="sa"
maxIdle="2"
maxWait="5000"
username="sa"
url="jdbc:jtds:sqlserver://10.0.0.5:1433/;DatabaseName=DEMODATA"
maxActive="4"/>
</GlobalNamingResources>
My web.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" 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">
<display-name>JNDITest</display-name>
<servlet>
<display-name>TestDataSource</display-name>
<servlet-name>TestDataSource</servlet-name>
<servlet-class>TestDataSource</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestDataSource</servlet-name>
<url-pattern>/TestDataSource</url-pattern>
</servlet-mapping>
<resource-ref>
<res-ref-name>jdbc/BookDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
Help!
Does anyone know how to fix this problem?
thanks
-
Can you post the code for your JNDI lookup?
-
here is my JNDI lookup , it is from the BOOKSTORE sample of J2eetutorial14. I just change database from Pointbase to SQL Server
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/BookDB");
con = ds.getConnection();
Similar Threads
-
By Barbocz Attila in forum Java
Replies: 0
Last Post: 04-26-2002, 08:01 AM
-
By Marc Boorshtein in forum Java
Replies: 0
Last Post: 08-13-2001, 11:27 AM
-
Replies: 1
Last Post: 05-11-2000, 05:44 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks