You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bojan Smojver <bo...@binarix.com> on 2001/09/12 14:09:36 UTC

Bug in TC 3.3 DependClassLoader

Since I was playing with distributing all my apps in jars...

In method dependency() of that class, there is a section for jars. It
goes something like this:

----------------------------
        if( "jar".equals( res.getProtocol() )) {
            String fileN=res.getFile();
            int idx=fileN.indexOf( "!" );
            if( idx>=0 )
                fileN=fileN.substring( 0, idx) ;
            f=new File( fileN );
            if( debug > 0 ) log( "Jar dep "  +f );
            if( ! f.exists()) f=null;
        }

        if( f==null ) return;
        Dependency dep=new Dependency();
        dep.setLastModified( f.lastModified() );
        dep.setTarget( c );
        dep.setOrigin( f );

        dependM.addDependency( dep );
----------------------------

So if the res is:

----------------------------
jar:file:/home/httpd/html/binarix.dev/WEB-INF/lib/app.jar!/com/binarix/wpm/ParseXML.class
----------------------------

then fileN after res.getFile() is:

----------------------------
file:/home/httpd/html/binarix.dev/WEB-INF/lib/app.jar!/com/binarix/wpm/ParseXML.class
----------------------------

and after tossing everything after the bang, it becomes:

----------------------------
file:/home/httpd/html/binarix.dev/WEB-INF/lib/app.jar
----------------------------

which is NOT a file (a URL maybe?), so f.exists() returns false and f
becomes null. The method dependency() returns without adding the jar in
question to the list of dependencies. Aieeeee!

Maybe there should be another 'file' section inside the 'jar' section to
resolve that URL?

If you guys think that'd work OK, I can write a little patch...

Bojan