Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trouble importing classes into servlet

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet that compiles

import statements:


which are found in .jar file that I created out of some code I found here:
http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower-p2.html
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
com/javaunderground/jdbc/SqlFormatter

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
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic