Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help: upgraded from tomcat 5.0 to 5.5.27 and getting Naming Exception

 
Ted Addis
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Please help what I am missing?
All I did was upgrade my tomcat from 5.0.17 to 5.5.27, the same application, same database and I am getting javax.naming.NamingException Name Jdbc is not bound in this context.

my context file is and already connect to the database through my oracle client.

<?xml version="1.0" encoding="UTF-8"?>
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="mydb" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc racle:thin:@10.1.4.156:1521:kwdb01" username="abcd" password="abcd" maxActive="20" maxIdle="10" maxWait="-1"/>
</Context>


and my java source code for connection would be
try
{
InitialContext initialcontext = new InitialContext();
try
{
Context context = (Context)(new InitialContext()).lookup("java:comp/env");
conn = ((DataSource)context.lookup("mydb")).getConnection();
 
Bhaskar Rao
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I dont know if its a change from Tomcat 5.0 to Tomcat 5.5. Try defining the resource name for the jdbc resource as 'jdbc/mydb' instead of 'mydb'.

I vaguely remember changing the resource name when I migrated my web app.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic