wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 12756
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: http://aspose.com/file-tools
subject: trouble importing classes into servlet
Similar Threads
What is a good book for learning Web Services ?
Viewing SQL from PreparedStatements
Java World example
DebuggableStatement - is it part of standard JDK
Printing PreparedStatements to log file