You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Angel Todorov <at...@gmail.com> on 2007/02/20 11:00:04 UTC

Classloading scenario

Hi All,

I have the following scenario: one webapp, which has some jars in its
private WEB-INF\lib dir, and one common jar which I would like to
share among several webapps. Hence, I am putting this jar into the
shared\lib directory of Tomcat. The problem is that this common lib
references classes which are in jars in the first webapp's WEB\lib
directory. Therefore, I get NoClassDefFoundErrors when this common jar
loads and tries to refer classes from the webapp's private lib.

Is it possible to achieve a workaround with tomcat's classloading for
that custom scenario?

Thank you very much in advance.

Regards,
Angel

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Classloading scenario

Posted by Luis Rivera <lu...@gmail.com>.
   Hi,

In my experience, since I have to use the JNI, I am forced to use the shared
space for some classes. The only way I made it work is to place everything
that is referenced by the classes in the shared space, in the shared space.
The classes in WEB-INF/.. have no problems accessing the shared classes,
since it is a parent class loader, but the converse does not work.

   --Luis R.

On 2/20/07, Peter Crowther <Pe...@melandra.com> wrote:
>
> > From: Angel Todorov [mailto:attodorov@gmail.com]
> > This doesn't work for me -> i would like to share classes between
> > webapps in order for them to have a common classloader. In this way i
> > can pass object references between two webapps.
>
> Then you'll have to put the jar you want *and all the classes and jars
> it depends on* in the shared space.
>
>                 - Peter
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Classloading scenario

Posted by Peter Crowther <Pe...@melandra.com>.
> From: Angel Todorov [mailto:attodorov@gmail.com] 
> This doesn't work for me -> i would like to share classes between
> webapps in order for them to have a common classloader. In this way i
> can pass object references between two webapps.

Then you'll have to put the jar you want *and all the classes and jars
it depends on* in the shared space.

		- Peter

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Classloading scenario

Posted by Angel Todorov <at...@gmail.com>.
Hi Boris,

This doesn't work for me -> i would like to share classes between
webapps in order for them to have a common classloader. In this way i
can pass object references between two webapps. In tomcat there is no
concept of EAR packaging, and EAR classloading isolation in general. I
don't agree that sharing classes doesn't pose many advantages as
compared to not sharing them - that's why there is the big topic named
"Jar Hell".

Regards,
Angel

On 2/20/07, Boris Unckel <bo...@gmx.net> wrote:
> Hello,
>
> Angel Todorov wrote:
> > I have the following scenario: one webapp, which has some jars in its
> > private WEB-INF\lib dir, and one common jar which I would like to
> > share among several webapps. Hence, I am putting this jar into the
> > shared\lib directory of Tomcat. The problem is that this common lib
> > references classes which are in jars in the first webapp's WEB\lib
> > directory. Therefore, I get NoClassDefFoundErrors when this common jar
> > loads and tries to refer classes from the webapp's private lib.
> >
> > Is it possible to achieve a workaround with tomcat's classloading for
> > that custom scenario?
> there is no workaround, but a better strategy and best practise:
> Put *all* JARs of a webapp into WEB-INF/lib, if there is not
> a strong usecase or technical reason to do otherwise (i.E. some JDBC drivers
> should be put into common/lib or shared/lib).
>
> Sharing classes causes definitly more problems than it solves.
>
> Regards
> Boris
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Classloading scenario

Posted by Boris Unckel <bo...@gmx.net>.
Hello,

Angel Todorov wrote:
> I have the following scenario: one webapp, which has some jars in its
> private WEB-INF\lib dir, and one common jar which I would like to
> share among several webapps. Hence, I am putting this jar into the
> shared\lib directory of Tomcat. The problem is that this common lib
> references classes which are in jars in the first webapp's WEB\lib
> directory. Therefore, I get NoClassDefFoundErrors when this common jar
> loads and tries to refer classes from the webapp's private lib.
>
> Is it possible to achieve a workaround with tomcat's classloading for
> that custom scenario?
there is no workaround, but a better strategy and best practise:
Put *all* JARs of a webapp into WEB-INF/lib, if there is not
a strong usecase or technical reason to do otherwise (i.E. some JDBC drivers
should be put into common/lib or shared/lib).

Sharing classes causes definitly more problems than it solves.

Regards
Boris


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org