views:

231

answers:

2

Hi,

could anyone please clarify the meaning of class libraries on the classpath in the case of Tomcat in the following line:

Actually all classes used by the web-app(unless they're part of the class libraries on the classpath) must follow the same rules as servlet classes-inside WEB-INF/classes, in a directory structure matching the package (or in the appropriate package directories within a JAR inside WEB-INF/lib).

What do they mean with class libraries and classpath in the above paragraph?

+2  A: 

Sounds like they're distinguishing between the .class files in your web app, packaged in a WAR file using the standard WEB-INF idiom, and those on the app server itself (e.g., in server/lib and common/lib for Tomcat 5.x and lib for Tomcat 6.x).

The important thing for you to know is that Tomcat has a hierarchy of class loaders. You need to understand how they work to use Tomcat effectively.

UPDATE: If understanding CLASSPATH is your issue, you need to know that anything WEB-INF/classes and in JARs under WEB-INF/lib in your deployment are in the CLASSPATH, along with JARs that are installed on your app server that all deployed applications share. That's what I meant when I said common/lib and server/lib for Tomcat 5.x and lib for Tomcat 6.

I don't think I understand what your question is. Do you not understand CLASSPATH? The CLASSPATH is all the places that the JVM knows to look when it needs a .class file that hasn't been loaded yet. That includes the JARs available to all applications deployed on Tomcat and WEB-INF/classes and WEB-INF/lib directories for your particular deployment.

duffymo
Sir, do you mean with 'classpath' here - the path of the classes in Tomcat, and with class libraries - the classes store in the Tomcat. Sorry, if don't understand you correctly.
+2  A: 

The classpath is a list of locations where the JVM should look to find classes. By default, this has things like rt.jar and vm.jar on it which contain the classes like java.lang.String. You can append directories and jars to the classpath to allow the VM to find classes beyond those installed by default.

A class library is a collection of classes packaged to be used by applications. For all practical purposes, it is a jar with useful classes in it like junit.jar.

What the message is saying is: If you want to use a library class (like something from log4j), it needs to be on the classpath, in WEB-INF/classes or WEB-INF/lib.

Aaron Maenpaa