You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by "Craig R. McClanahan" <cm...@mytownnet.com> on 2000/01/17 16:32:45 UTC

Re: Automagic loading of WEB-INF/lib???

Daniel Rejment wrote:

> I may have completely misunderstood the web-inf thing but
> when I try to put my servlets in a Jar file under WEB-INF/lib/
> tomcat reports:
>
> cannot load servlet name: testservlet
>
> I believe that I have set up my web.xml correctly.
> If I put the classes under WEB-INF/classes/ everything
> works as it should.
>

The WEB-INF/lib directory is only scanned for JAR files, not for
unpacked classes.  If you JAR'd up your servlets and put them in
WEB-INF/lib they will be found.

As you discovered, you can leave your servlets unpacked by putting them
in WEB-INF/classes instead.  That is why both directory names were
defined in the servlet spec.

>
> Grateful for any help...
>

Craig McClanahan



Re: Automagic loading of WEB-INF/lib???

Posted by Fergus Gallagher <Fe...@OrbisUK.com>.
Just for support, I tried the same thing, without joy.

Fergus

Daniel Rejment wrote:
> 
> > Daniel Rejment wrote:
> >
> > > I may have completely misunderstood the web-inf thing but
> > > when I try to put my servlets in a Jar file under WEB-INF/lib/
> > > tomcat reports:
> > >
> > > cannot load servlet name: testservlet
> > >
> > > I believe that I have set up my web.xml correctly.
> > > If I put the classes under WEB-INF/classes/ everything
> > > works as it should.
> > >
> >
> > The WEB-INF/lib directory is only scanned for JAR files, not for
> > unpacked classes.  If you JAR'd up your servlets and put them in
> > WEB-INF/lib they will be found.
> >
> > As you discovered, you can leave your servlets unpacked by putting them
> > in WEB-INF/classes instead.  That is why both directory names were
> > defined in the servlet spec.
> >
> 
> I did indeed JAR the files that were put in WEB-INF/lib. These JARs where successfully used in another servlet container (LWS2.1) and also works when they are put in the tomcat classpath. They just aren't automagically loaded. What gives? Could there be something missing in the files that stops the classloader from using them? According to the source, the implementation of JAR loading is somewhat flaky, but it doesn't quite specify how and I couldn't find anything wrong with it.
> 
> /Daniel
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org

-- 
Fergus Gallagher          Tel: +44 (20) 89 87 07 17
Orbis                     Fax: +44 (20) 87 42 26 49
The Swan Centre           email: Fergus.Gallagher@orbisuk.com
Fishers Lane              Web: http://www.orbisuk.com
London W4 1RX / UK

Re: Automagic loading of WEB-INF/lib???

Posted by Danno Ferrin <sh...@earthlink.net>.
It's been patched, RC2 should have the fix, or thr head of the CVS.

--Danno

----- Original Message -----
From: "Fergus Gallagher" <Fe...@OrbisUK.com>
To: <ge...@jakarta.apache.org>
Sent: Tuesday, January 18, 2000 5:01 AM
Subject: Re: Automagic loading of WEB-INF/lib???


> Hi,
>
>
> I couldn't get that to work - I think a / is missing
> (basepath+"/"+libpath+"/"+jarfile), similarly in line a bit above
>
>             File f =  new File(basepath + "/" +libpath + "/");
>
> I actually tried this in 3.1 RC1 - ServletClassLoaderImpl - but relevant
> code look identical.
>
> Sorry I'm not fully diff-aware!
>
> Fergus
>
> Lars Hofhansl wrote:
> >
> > Hi,
> >
> > the stock tomcat 3.0 contains a bug that'll prevent jar files
> > in the WEB-INF/lib directory from being searche for classes.
> >
> > I'm astonished that nobody else went into this problem so far.
> >
> > Anyway, here's a tiny patch to fix that:
> >
> > ---------------------- snip --------------------------
> > diff -u -r
> > jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.ja
> > va
> >
jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
> > ---
> > jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.java
> > Wed Dec 15 17:49:52 1999
> > +++
> >
jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
> > Sun Jan 16 17:45:04 2000
> > @@ -127,7 +127,7 @@
> >                  try {
> >                      String jarfile = (String) jars.elementAt(i);
> >                      URL jarURL = new URL(protocol,hostname,port,
> > -                                         basepath + jarfile);
> > +                                         basepath +
> > libpath+"/"+jarfile);
> >                      addURL(jarURL);
> >                  }catch(MalformedURLException mue) {
> >                  }
> > ----------------------- snip --------------------------
> >
> > 'hope that helps,
> >
> >         Lars
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: general-help@jakarta.apache.org
>
> --
> Fergus Gallagher          Tel: +44 (20) 89 87 07 17
> Orbis                     Fax: +44 (20) 87 42 26 49
> The Swan Centre           email: Fergus.Gallagher@orbisuk.com
> Fishers Lane              Web: http://www.orbisuk.com
> London W4 1RX / UK
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
>
>


Re: Automagic loading of WEB-INF/lib???

Posted by Lars Hofhansl <lh...@poet.com>.
Hi,

obviously my mail reader wrapped that line.

Just apply the modification by hand... It's
only adding the libpath to the jarURL...

	Lars


Fergus Gallagher wrote:
> 
> Hi,
> 
> I couldn't get that to work - I think a / is missing
> (basepath+"/"+libpath+"/"+jarfile), similarly in line a bit above
> 
>             File f =  new File(basepath + "/" +libpath + "/");
> 
> I actually tried this in 3.1 RC1 - ServletClassLoaderImpl - but relevant
> code look identical.
> 
> Sorry I'm not fully diff-aware!
> 
> Fergus
> 
> Lars Hofhansl wrote:
> >
> > Hi,
> >
> > the stock tomcat 3.0 contains a bug that'll prevent jar files
> > in the WEB-INF/lib directory from being searche for classes.
> >
> > I'm astonished that nobody else went into this problem so far.
> >
> > Anyway, here's a tiny patch to fix that:
> >
> > ---------------------- snip --------------------------
> > diff -u -r
> > jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.ja
> > va
> > jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
> > ---
> > jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.java
> > Wed Dec 15 17:49:52 1999
> > +++
> > jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
> > Sun Jan 16 17:45:04 2000
> > @@ -127,7 +127,7 @@
> >                  try {
> >                      String jarfile = (String) jars.elementAt(i);
> >                      URL jarURL = new URL(protocol,hostname,port,
> > -                                         basepath + jarfile);
> > +                                         basepath +
> > libpath+"/"+jarfile);
> >                      addURL(jarURL);
> >                  }catch(MalformedURLException mue) {
> >                  }
> > ----------------------- snip --------------------------
> >
> > 'hope that helps,
> >
> >         Lars
> >

Re: Automagic loading of WEB-INF/lib???

Posted by Fergus Gallagher <Fe...@OrbisUK.com>.
Hi, 


I couldn't get that to work - I think a / is missing
(basepath+"/"+libpath+"/"+jarfile), similarly in line a bit above
 
            File f =  new File(basepath + "/" +libpath + "/");

I actually tried this in 3.1 RC1 - ServletClassLoaderImpl - but relevant
code look identical.

Sorry I'm not fully diff-aware!

Fergus

Lars Hofhansl wrote:
> 
> Hi,
> 
> the stock tomcat 3.0 contains a bug that'll prevent jar files
> in the WEB-INF/lib directory from being searche for classes.
> 
> I'm astonished that nobody else went into this problem so far.
> 
> Anyway, here's a tiny patch to fix that:
> 
> ---------------------- snip --------------------------
> diff -u -r
> jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.ja
> va
> jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
> ---
> jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.java
> Wed Dec 15 17:49:52 1999
> +++
> jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
> Sun Jan 16 17:45:04 2000
> @@ -127,7 +127,7 @@
>                  try {
>                      String jarfile = (String) jars.elementAt(i);
>                      URL jarURL = new URL(protocol,hostname,port,
> -                                         basepath + jarfile);
> +                                         basepath +
> libpath+"/"+jarfile);
>                      addURL(jarURL);
>                  }catch(MalformedURLException mue) {
>                  }
> ----------------------- snip --------------------------
> 
> 'hope that helps,
> 
>         Lars
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org

-- 
Fergus Gallagher          Tel: +44 (20) 89 87 07 17
Orbis                     Fax: +44 (20) 87 42 26 49
The Swan Centre           email: Fergus.Gallagher@orbisuk.com
Fishers Lane              Web: http://www.orbisuk.com
London W4 1RX / UK

Re: Automagic loading of WEB-INF/lib???

Posted by Geoff Vona <ga...@klgroup.com>.

Lars Hofhansl wrote:

> Hi,
>
> the stock tomcat 3.0 contains a bug that'll prevent jar files
> in the WEB-INF/lib directory from being searche for classes.
>
> I'm astonished that nobody else went into this problem so far.

  I ran into this problem back on Jan 4th, and posted to
this list, but nothing came of it. :(

  At least I'm glad to learn that I'm not crazy, and the problem
is real. :)

--
Geoff Vona --- KL Group --- http://www.klgroup.com



Re: Automagic loading of WEB-INF/lib???

Posted by Lars Hofhansl <lh...@poet.com>.
Daniel Rejment wrote:
> 
> > Daniel Rejment wrote:
> >
> > > I may have completely misunderstood the web-inf thing but
> > > when I try to put my servlets in a Jar file under WEB-INF/lib/
> > > tomcat reports:
> > >
> > > cannot load servlet name: testservlet
> > >
> > > I believe that I have set up my web.xml correctly.
> > > If I put the classes under WEB-INF/classes/ everything
> > > works as it should.
> > >
> >
> > The WEB-INF/lib directory is only scanned for JAR files, not for
> > unpacked classes.  If you JAR'd up your servlets and put them in
> > WEB-INF/lib they will be found.
> >
> > As you discovered, you can leave your servlets unpacked by putting them
> > in WEB-INF/classes instead.  That is why both directory names were
> > defined in the servlet spec.
> >
> 
> I did indeed JAR the files that were put in WEB-INF/lib. These JARs where successfully used in another servlet container (LWS2.1) and also works when they are put in the tomcat classpath. They just aren't automagically loaded. What gives? Could there be something missing in the files that stops the classloader from using them? According to the source, the implementation of JAR loading is somewhat flaky, but it doesn't quite specify how and I couldn't find anything wrong with it.

> 
> /Daniel
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org

Hi,

the stock tomcat 3.0 contains a bug that'll prevent jar files
in the WEB-INF/lib directory from being searche for classes.

I'm astonished that nobody else went into this problem so far.

Anyway, here's a tiny patch to fix that:

---------------------- snip --------------------------
diff -u -r
jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.ja
va
jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java
---
jakarta-tomcat/src/share/org/apache/tomcat/core/ServletClassLoader.java     
Wed Dec 15 17:49:52 1999
+++
jakarta-tomcat.new/src/share/org/apache/tomcat/core/ServletClassLoader.java 
Sun Jan 16 17:45:04 2000
@@ -127,7 +127,7 @@
                 try {
                     String jarfile = (String) jars.elementAt(i);
                     URL jarURL = new URL(protocol,hostname,port,
-                                         basepath + jarfile);
+                                         basepath +
libpath+"/"+jarfile);
                     addURL(jarURL);
                 }catch(MalformedURLException mue) {
                 }
----------------------- snip --------------------------

'hope that helps,

	Lars

RE: Automagic loading of WEB-INF/lib???

Posted by Daniel Rejment <da...@jpss.se>.
> Daniel Rejment wrote:
> 
> > I may have completely misunderstood the web-inf thing but
> > when I try to put my servlets in a Jar file under WEB-INF/lib/
> > tomcat reports:
> >
> > cannot load servlet name: testservlet
> >
> > I believe that I have set up my web.xml correctly.
> > If I put the classes under WEB-INF/classes/ everything
> > works as it should.
> >
> 
> The WEB-INF/lib directory is only scanned for JAR files, not for
> unpacked classes.  If you JAR'd up your servlets and put them in
> WEB-INF/lib they will be found.
> 
> As you discovered, you can leave your servlets unpacked by putting them
> in WEB-INF/classes instead.  That is why both directory names were
> defined in the servlet spec.
> 

I did indeed JAR the files that were put in WEB-INF/lib. These JARs where successfully used in another servlet container (LWS2.1) and also works when they are put in the tomcat classpath. They just aren't automagically loaded. What gives? Could there be something missing in the files that stops the classloader from using them? According to the source, the implementation of JAR loading is somewhat flaky, but it doesn't quite specify how and I couldn't find anything wrong with it.

/Daniel