• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Class.forName problem on Tomcat 4

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a problem with trying to dynamically load a class from a 3rd party jar on Tomcat. I can see lots of other people have experienced the problem but I couldn't get a clear answer and I seem to be following the classloader instructions in the Tomcat how-to.

I have my jar file in the web-inf/lib dir of my web app (its the Lucene 1.9.1 jar). I am attempting to load a class like this:



If I reference the class directly, theres no problem. Otherwise it throws a ClassNotFoundException. I've checked the web app on the server and the lib is definitely there. I also tried explicitly adding the lucene jar to the tomcat classpath, and in the common/lib dir, although I understand the latter is not best practice.

Is there anything extra I need to do?

Many thanks for your advice



Marc
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by marc dauncey:

I have my jar file in the web-inf/lib dir of my web app (its the Lucene 1.9.1 jar). I am attempting to load a class like this:



Did your really spell the directory "web-inf"?
Or did you mean to type "WEB-INF"?

If it is spelled with lower case letters, that could be why the container is not finding it. If it's not, please be more careful when posting questions here so that you don't waste people's time with bugs that don't actually exist in your real environment.
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to pass Class.forName the fully qualified name of your class (eg: java.lang.String)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!