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 07:40:26 GMT
>Apparently, individual jars should be added as URLs rather than
>normal file system paths.  I suppose that means using
>file:///<path>/<file>.jar, but I haven't tried it.

I guess that would work because Bootstrap.java has the following piece of code in its createClassLoader(String,
ClassLoader)

---------------------------------------------------------
		// Check for a JAR URL repository
            try {
                urlList.add(new URL(repository));
                continue;
            } catch (MalformedURLException e) {
                // Ignore
            }
---------------------------------------------------------

Chuck, but would not be better if we fix the actual problem in the ClassLoaderFactory#createClassLoader.
Then people would not be spending time working out why they cannot load a jar file :)  We
already have a fix - see below :

-------FIX---------in ClassLoaderFactory#createClassLoader-----------------------
// Add unpacked directories
//        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 " 
//                        + file.getAbsolutePath());
//                URL url = new URL("file", null,
//                                  file.getCanonicalPath() + File.separator);
//                list.add(url.toString());
//            }
//        }
		// 
		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 " 
                        + file.getAbsolutePath());
                
                // THE FIX !!!!!!!!!!!
                StringBuffer filePath = new StringBuffer(file.getCanonicalPath());
                if ( file.isDirectory() ) { 
                	// Only add a file separator if a file represents a directory
                	filePath.append(File.separator);
                }
                                
                URL url = new URL("file", null, filePath.toString());
                list.add(url.toString());
            }
        }

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


Please let me know what you think....




-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Friday, 22 April 2005 4:09 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]

> Subject: RE: Problem with the classloader in 
> jakarta-tomcat-5.0.28 - cannot add a jar file to class repository
> 
> However, if you add a reference to the actual jar file (eg, 
> shared.loader=${catalina.home}/shared/lib/velocity-dep-1.3.1.j
> ar) you will not be able to use any classes from it but 
> rather will get ClassNotFoundException. This is the actual problem!

This appears to be the same situation described in Bugzilla entry 23344
(see
	http://issues.apache.org/bugzilla/show_bug.cgi?id=23344
for details) which was marked as fixed in September 2003 in level
5.0.12.  Apparently, individual jars should be added as URLs rather than
normal file system paths.  I suppose that means using
file:///<path>/<file>.jar, but I haven't tried it.

 - 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