File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes issue locating a jar file for for logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "issue locating a jar file for for logging" Watch "issue locating a jar file for for logging" New topic

issue locating a jar file for for logging

Fran Varin

Joined: Aug 08, 2003
Posts: 22
We are using Tomcat 4.1 and jdk 1.4.2. We have written some customized handlers and formatters, these classes are contained in a common Jar file. The only way we can get Tomcat to see the jar file is if it resides in the Java JRE's lib\ext directory. We have tried classpathing the jar but, it seems that Tomcat's initial startup does not see the jar resulting ain a ClassNotFoundException.

Putting the jar in the "ext" directory is OK but, we run into dependencies that now require additional jar files to be included there as well. Also, classes that reside in web applications can run into class loader issues because the common jar has been loaded by a different class loader.

My question is...have we missed the point with Tomcat? Is there a different approach that we should consider in having Tomcat see the jar file. We're new to using Tomcat and are not too familiar with its nuances.

Any help would be appreciated.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Tomcat ignores your classpath (as you have already seen).
Instead it looks for classes and jars in a pre-defined list of directories.

For libraries local to your webapp only, place the jar files in your app's WEB-INF/lib directory.

For libraries to be shared among all webapps, place them in the tomcat/shared/lib directory.

For libraries to be shared amoung all webapps, and the Tomcat server itself, place them in the tomcat/common/lib directory.

for more details.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Fran Varin

Joined: Aug 08, 2003
Posts: 22
Hi Ben,
Thanks for the reply. I reviewed your post and the link you sent. I tried the following class loaders with the corresponding result:

Bootstrap (works)
System (Could not use because I'm starting from a .bat file)
Common (ClassNotFound)
Catalina (ClassNotFound)
Shared (ClassNotFound)

I'm wondering if this is a nuance in using java.util.logging. It appears to be started very early in the process and I'm wondering if it MUST be associated with the bootstrap class loader?

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

If you check out the API documentation for the java.util.logging.LogManager class, you will see these statements:

"There is a single global LogManager object"

"The LogManager object is created during class initialization"

"At startup the LogManager class is located using the java.util.logging.manager system property"

"Note that all classes loaded during LogManager configuration must be on the system class path" (the question you asked)

and others that combine to suggest that there is only one LogManager object per JVM. In other words, it is a centralized logging facility. If you have several web applications and you want to configure logging for them, you have to go to the single centralized configuration file and modify that.

If you prefer to manage logging separately for each web application, and provide handlers in a jar file that is part of the web application, then I recommend you use log4J instead. That's what I do.
Fran Varin

Joined: Aug 08, 2003
Posts: 22
Thanks...I really appreciate the input. I've seperated the classes into their own jar file and included them on the boot class path. I still don't fully see why the classes are not seen by the classpath when the jvm starts up though.
Don't get me started about those stupid light bulbs.
subject: issue locating a jar file for for logging
It's not a secret anymore!