• 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 ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

First Servlet, Jdbc program :(

 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to write a code that retrieves info from database and show it on the web. I couldn't view it through Tomcat, I don't understand the reason. Can anyone explain it to me?
This is my code:

I am using correct userid and password. I tried a Jdbc program seperately it works fine. But here it throws Exception.
Just couple of lines of the exception.
javax.servlet.ServletException: Cannot allocate servlet instance for path /examples/servlet/ShowEmployees
root cause
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
Thanks,
Vanitha.

[This message has been edited by Vanitha Sugumaran (edited November 18, 2001).]
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the exception given it's clear that the oracle drivers aren't on the classpath that Tomcat is using...
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your stand-alone program will use the System CLASSPATH, and thus find your Oracle drivers.

Tomcat 4.0.x does not use System CLASSPATH, so you must include your Oracle drivers in the library directory <tomcat-home>/common/lib

This makes it available to any application running under Tomcat, or you can alternately place classes.zip (the Oracle drivers) under the <webcontext>/WEB-INF/lib directory of each webapp that needs db connections.

I also seem to recall that Tomcat doesn't like zip'd files, so simply rename classes.zip to classes.jar

Hope that helps.
 
Vanitha Sugumaran
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kyle and Mike for your replies.
I copied the classes12.zip, modified to jar file, I kept the classes.jar file in <tomcat home>/common/lib --> didn't work same error.
<tomcat home>/server/lib --> didn't work.
I couldn't find lib dir in the webapps/web-inf directory.
I don't know where else should I keep the classes12.jar file, can anyone give some suggestions please?
Thanks.
Vanitha
 
Vanitha Sugumaran
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a seperate Jdbc program in the tomcat directory it is working, if I mix it with servlet then it is not working what might be the problem?
this is my code for jdbc program:

After keeping the classess.zip do we have specify any path name?
I have to finish my class project with in a week, so if anyone can solve my problem that would be great.
Vanitha.
[This message has been edited by Vanitha Sugumaran (edited November 19, 2001).]
 
Vanitha Sugumaran
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I have to change anything in server.xml?
Vanitha.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For Oracle JDBC the key for Apache Jakarta Tomcat 5 is to place the classes111.zip file in the subdirectory common/lib with the jar extension. So rename the Oracle file classes111.zip to classes111.jar and copy to <installed directory>/common/lib/classes111.jar. Then stop and restart the server. It should work.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using JDK 1.4.x you'll need ojdbc.jar(from Oracle) in common\lib
 
reply
    Bookmark Topic Watch Topic
  • New Topic