You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by eric ng <ch...@yahoo.com> on 2001/06/08 01:16:03 UTC

/lib & /WEB-INF/lib

Hi,
In tomcat or other servlet engine implements the spec.
 there are 2 place to put JAR files:

1) d:/tomcat/lib
2) d:/tomcat/webapps/abc/WEB-INF/lib

I wonder what's the difference putting JAR in the 2
directory? any performance difference? Should I always
put JAR into web apps's own lib?

thanks.


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Re: /lib & /WEB-INF/lib

Posted by Hemant Singh <he...@yahoo.com>.
HI:
If you have a jar which you are using in more than  one web-apps than place
it under
/tomat/lib
so that tomcat do not reload the same jar more than once(I really surprise
how internally it works)

and if you are using that jar only in one web-app than place than place it
under
/tomcat/webappps/yourwebapp/web-inf/lib

Regards
Hemant
----- Original Message -----
From: "Bo Xu" <bo...@cybershop.ca>
To: <to...@jakarta.apache.org>
Sent: Friday, June 08, 2001 7:02 PM
Subject: Re: /lib & /WEB-INF/lib


> eric ng wrote:
>
>
> > Hi,
> > In tomcat or other servlet engine implements the spec.
> >  there are 2 place to put JAR files:
> >
> > 1) d:/tomcat/lib
> > 2) d:/tomcat/webapps/abc/WEB-INF/lib
> >
> > I wonder what's the difference putting JAR in the 2
> > directory? any performance difference? Should I always
> > put JAR into web apps's own lib?
> >
> > thanks.
> > [...]
>
> Hi :-)
>
> - the jar files in TOMCAT_HOME/sebapps/myapp/WEB-INFlib
>   are loaded by the classloader of this webapp(myapp), normally they
>   are only used in this webapp(myapp).
>
> - the jar files in TOMCAT_HOME/lib are loaded by another classloader
>    (SharedClassloader) which is "upper" than the classloader of this
> webapp
>    or that webapp in "JAVA2 delegation model", these jar files are
> "shared"
>    for all webapp(0) or webapp(1) or webapp(2)...
>       % If you want to share a utility class to all webapp, you can wrap
>
>            it into a jar file, and put the jar file here.
>       % because sometimes the classloader of one special webapp(for
> example,
>            myapp) will be destroyed(for example, auto-reloading), so If
> you don't
>            want a utility class to be load/reload several times, you can
> wrap
>            it into a jar file, and put the jar file here.
>
>
> Bo
> June.08, 2001
>


Re: /lib & /WEB-INF/lib

Posted by Bo Xu <bo...@cybershop.ca>.
eric ng wrote:


> Hi,
> In tomcat or other servlet engine implements the spec.
>  there are 2 place to put JAR files:
>
> 1) d:/tomcat/lib
> 2) d:/tomcat/webapps/abc/WEB-INF/lib
>
> I wonder what's the difference putting JAR in the 2
> directory? any performance difference? Should I always
> put JAR into web apps's own lib?
>
> thanks.
> [...]

Hi :-)

- the jar files in TOMCAT_HOME/sebapps/myapp/WEB-INFlib
  are loaded by the classloader of this webapp(myapp), normally they
  are only used in this webapp(myapp).

- the jar files in TOMCAT_HOME/lib are loaded by another classloader
   (SharedClassloader) which is "upper" than the classloader of this
webapp
   or that webapp in "JAVA2 delegation model", these jar files are
"shared"
   for all webapp(0) or webapp(1) or webapp(2)...
      % If you want to share a utility class to all webapp, you can wrap

           it into a jar file, and put the jar file here.
      % because sometimes the classloader of one special webapp(for
example,
           myapp) will be destroyed(for example, auto-reloading), so If
you don't
           want a utility class to be load/reload several times, you can
wrap
           it into a jar file, and put the jar file here.


Bo
June.08, 2001



Re: /lib & /WEB-INF/lib

Posted by Milt Epstein <me...@uiuc.edu>.
On Thu, 7 Jun 2001, eric ng wrote:

> Hi,
> In tomcat or other servlet engine implements the spec.
>  there are 2 place to put JAR files:
>
> 1) d:/tomcat/lib
> 2) d:/tomcat/webapps/abc/WEB-INF/lib
>
> I wonder what's the difference putting JAR in the 2
> directory? any performance difference? Should I always
> put JAR into web apps's own lib?

The main difference is a functional/modular one: Things in 1) will be
seen by all webapps/contexts, things in 2) will be seen only by the
one webapp/context.  In certain situations (e.g. you only have one
webapp/context), there'd be no difference.  There might be performance
differences, I don't know, but I suspect they'd be minor.

So things that need to be seen by all webapps/contexts need to be in
1).  Things that only need to be seen by one webapp/context could
conceivably go in either 1) or 2).  As a matter of clean design, I'd
suggest these latter things go in 2).

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu