File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes trouble importing classes into servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "trouble importing classes into servlet" Watch "trouble importing classes into servlet" New topic

trouble importing classes into servlet

Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

I have a servlet that compiles

import statements:

which are found in .jar file that I created out of some code I found here:
The purpose is to view a String of a prepared statement as it looks as it is interpreted by the database.

When the servlet runs, I get the noClassDefFound error that it can't find

which is an abstract class extended by OracleSqlFormatter:

and is present in the .jar file
I am wondering why my servlet can't find this class but it can find other classes in the same jar file??
I am wondering if I made my jar file wrong somehow?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
The first question is - where did you put the Jar file? Tomcat does not use your environment CLASSPATH.
Your Tomcat installation has a nice discussion of how Tomcat finds files in the webapps/tomcat-docs/class-loader-howto.html file.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Thanks for your reply. I was sure I had placed it in the lib directory of my web application, but when I looked at the behest of someone here, lo, it wasn't there.
Now to fix my build.xml to move the .jars when I deploy so I don't make this mistake again..
I agree. Here's the link:
subject: trouble importing classes into servlet
It's not a secret anymore!