tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akoulov, Alexandre [IT]" <alexandre.akou...@citigroup.com>
Subject RE: Problem with the classloader in jakarta-tomcat-5.0.28 - cannot add a jar file to class repository
Date Fri, 22 Apr 2005 05:46:35 GMT
>The standard catalina.properties already has several jars and several
>directories specified for the various class loaders,

standard catalina.properties has refs to "*.jar" (eg, ${catalina.home}/common/endorsed/*.jar)
not to the actual jar file. 

Bootstrap.java then checks whether there is "*.jar" at the end of the path, strips it from
the path and then adds to the packed list. If the path ends in anything other than "*.jar"
it gets added to unpacked list (that is where the jar file ends up)

--------------------------------------------------------------
		if (repository.endsWith("*.jar")) {
                packed = true;
                repository = repository.substring
                    (0, repository.length() - "*.jar".length());
            }
            if (packed) {
                packedList.add(new File(repository));
            } else {
                unpackedList.add(new File(repository));
            }
--------------------------------------------------------------

However, if you add a reference to the actual jar file (eg, shared.loader=${catalina.home}/shared/lib/velocity-dep-1.3.1.jar)
you will not be able to use any classes from it but rather will get ClassNotFoundException.
This is the actual problem!



>Read the javadoc for the class in question.  (The full URL is
>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/catalina/docs/api/org/ap
>ache/catalina/startup/ClassLoaderFactory.html#createClassLoader(java.io.
>File[],%20java.io.File[],%20java.net.URL[],%20java.lang.ClassLoader).)


Well, the java doc says that "packed - Array of pathnames to DIRECTORIES CONTAINING JAR files
that should be added to the repositories of the class loader, or null for no directories of
JAR files to be considered" (not the actual jar files!!!!). 
At the same time java doc indicates that "unpacked - Array of pathnames to unpacked directories
that should be added to the repositories of the class loader, or null for no unpacked directories
to be considered". I guess here it means that a jar file is already considered to be unpacked
directory. This conclusion can be drawn from the Bootstrap.java code extract (see above) and
more importantly from the actual ClassLoaderFactory#createClassLoader method's source:

------------------------------------------------

	if (unpacked != null) {
           	for (int i = 0; i < unpacked.length; i++)  {
                File file = unpacked[i];
                if (!file.exists() || !file.canRead())
                    continue;
                if (debug >= 1)
                    log("  Including directory or JAR "  // LOOK HERE - expects directory
or a JAR file
                        + file.getAbsolutePath());
	..............
	..............
	if (packed != null) {
            for (int i = 0; i < packed.length; i++) {
                File directory = packed[i];
                if (!directory.isDirectory() || !directory.exists() ||
                    !directory.canRead()) 	// LOOK HERE - only expects to find directories
in here, not the files!!!!!!!!!!!
                    continue;                
------------------------------------------------


-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Friday, 22 April 2005 3:13 PM
To: Tomcat Users List
Subject: RE: Problem with the classloader in jakarta-tomcat-5.0.28 -
cannot add a jar file to class repository


> From: Akoulov, Alexandre [IT] [mailto:alexandre.akoulov@citigroup.com]

> Sent: 2005 April 21, Thursday 19:48
> Subject: RE: Problem with the classloader in 
> jakarta-tomcat-5.0.28 - cannot add a jar file to class repository
> 
> I still think it is a bug!!! 

Read the javadoc for the class in question.  (The full URL is
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/catalina/docs/api/org/ap
ache/catalina/startup/ClassLoaderFactory.html#createClassLoader(java.io.
File[],%20java.io.File[],%20java.net.URL[],%20java.lang.ClassLoader).)
The first parameter is for directories, the second for jars, which is
why they're named "unpacked" and "packed", respectively.  

> Please try the following: add a jar file (eg, foo/bar.jar) as 
> a class repository in the catalina.properties

The standard catalina.properties already has several jars and several
directories specified for the various class loaders, and they all seem
to work fine in the levels I'm using (5.0.28 and 5.5.7) - otherwise
Tomcat wouldn't even be able to start up.  What specifically did you
change in catalina.properties that led you to believe there's a problem?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message