Re: Bug in TC 3.3 DependClassLoader

2001-09-12 Thread Bojan Smojver

Bojan Smojver wrote:
> 
> [EMAIL PROTECTED] wrote:
> >
> > Sorry, I had a lot on my had in the last days.
> >
> > Bojan - if you want to send a patch, it would be great. If not - I can fix
> > the bug ( but I would prefer you to send a patch - who knows, maybe later
> > you'll send another one, the first is allways harder :-)
> >
> > Costin
> 
> Sorry, had to sleep ;-)
> 
> I already have the code, but I'm still testing to make sure it does
> work. You'll have it this morning (Sydney time).
> 
> Bojan

This does the trick for me...

Bojan

--- 
/home/groups/devel/jakarta/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java
Tue Sep 11 17:42:11 2001
+++ src/share/org/apache/tomcat/util/depend/DependClassLoader.java  Thu Sep 13 
+09:05:00 2001
@@ -238,9 +238,16 @@
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;
+
+try{
+  f=new File(new URL(fileN).getFile());
+  if( debug > 0 ) log( "Jar dep "  +f );
+  if( ! f.exists()) f=null;
+} catch(NullPointerException npe){
+  f=null;
+} catch(MalformedURLException mue){
+  f=null;
+}
}
 
if( f==null ) return;



Re: Bug in TC 3.3 DependClassLoader

2001-09-12 Thread Bojan Smojver

[EMAIL PROTECTED] wrote:
> 
> Sorry, I had a lot on my had in the last days.
> 
> Bojan - if you want to send a patch, it would be great. If not - I can fix
> the bug ( but I would prefer you to send a patch - who knows, maybe later
> you'll send another one, the first is allways harder :-)
> 
> Costin

Sorry, had to sleep ;-)

I already have the code, but I'm still testing to make sure it does
work. You'll have it this morning (Sydney time).

Bojan



RE: Bug in TC 3.3 DependClassLoader

2001-09-12 Thread cmanolache

Sorry, I had a lot on my had in the last days.

Bojan - if you want to send a patch, it would be great. If not - I can fix
the bug ( but I would prefer you to send a patch - who knows, maybe later
you'll send another one, the first is allways harder :-)


Costin

On Wed, 12 Sep 2001, Larry Isaacs wrote:

> Hi Bojan,
>
> Costin is the expert on this section of code.  I need to become
> more familiar with it, so I'm willing to take a look.  If you can
> submit a patch, that would be helpful.  If you need to wait for
> Costin's advice, I understand.  On occasion, I have had to do
> the same.
>
> Cheers,
> Larry
>
> > -Original Message-
> > From: Bojan Smojver [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 12, 2001 8:10 AM
> > To: Tomcat Dev List
> > Subject: 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/bin
> arix/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. Aie!
>
> 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
>




RE: Bug in TC 3.3 DependClassLoader

2001-09-12 Thread Larry Isaacs

Hi Bojan,

Costin is the expert on this section of code.  I need to become
more familiar with it, so I'm willing to take a look.  If you can
submit a patch, that would be helpful.  If you need to wait for
Costin's advice, I understand.  On occasion, I have had to do
the same.

Cheers,
Larry

> -Original Message-
> From: Bojan Smojver [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 12, 2001 8:10 AM
> To: Tomcat Dev List
> Subject: 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/bin
arix/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. Aie!

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