• Post Reply Bookmark Topic Watch Topic
  • New Topic

Annoying ClassNotFoundException....

 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm deploying a web application to a server and when I went to test my page, I got a ClassNotFoundException: org.apache.xerces.parsers.SAXParser
Not a problem; I discovered that I forgot to upload the .JAR file that contained that class to the server.
Now, however, my .JAR file is in ,y /WEB-INF/lib directory and I am still getting this error. I've tried everything, including packaging all the xerces/xml packages into my other JAR file in the lib directory. No matter what I do, it gives me this error. What more should I need to do? Do I have to have the Tomcat server restarted? Or does somebody know if there is some class that the SAXparser is looking for but can't find, and as such throws the CNF Exception?
In case it matters, the hosting service is hostignition.com
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that Tomcat has to be restarted when you add something to the lib directory. Another possible cause is if the jar file is in multiple places in the classpath. I have had that cause problems, particularly with Struts bases web apps.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Matthew Phillips:
I believe that Tomcat has to be restarted when you add something to the lib directory

That could be annoying, since I have to go through tech support to get things like this done.
What about adding the classes to the existing .jar file there? I see other changes that I make to that .jar file, but it still can't find the SAXParser class.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could this be a classloader problem?
If the class trying to find SAXParser is loaded by the system classloader, then it won't find it from within your webapp (WEB-INF/lib).
In other words, let's say that you've got the factory class (which creates the parser instances) somewhere in a global lib directory, thus getting loaded by the system classloader, and that the SAXParser class is only available in WEB-INF/lib. This means trouble - system classloader does not see classes loaded by the webapp classloader. The solution in this kind of situation would be to either
A) move the factory class from system lib to webapp lib directory
or
B) move the SAXParser class from webapp lib to system lib directory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!