You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by André Warnier <aw...@ice-sa.com> on 2009/02/27 18:56:26 UTC

classloaders ?

Hi.

I am a superficial browser on this list and tend not to delve to deep 
into Java intricacies.  But when a term consistently shows up which I do 
not understand, I try to at least learn enough about it to be able to 
reassure my customers.

Classloader is now such a term.

I gather it is something that the JVM calls when it's missing a class, 
to go hunt it down along a logic all its own, and kind of bring it into 
service. I also gather that it's rather bad to get one's classloader 
confused by setting CLASSPATHs and the like. And I gather that you can 
either have your very own, or rely on Tomcat (?) to provide a standard 
one.  I haven't a clue however if this is something Tomcat-specific, 
Java-generic, or in-between.

Since I doubt that the above is all there is to say about it, could 
someone thus be as kind as to point me to an explanation/tutorial about 
classloaders ?

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


RE: classloaders ?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: classloaders ?
>
> Looks like I'm not the only one to be confused though,
> classloaders often are too..  JAR Hell, my my.

Not quite as bad as DLL hell, but similar in practice.

Don't forget Tomcat's own classloader doc:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html


 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


Re: classloaders ?

Posted by André Warnier <aw...@ice-sa.com>.
Youssef Mohammed wrote:
> http://en.wikipedia.org/wiki/Java_Classloadercheck the references over there
> ...
Thanks.
That seems a good one.  Looks like I'm not the only one to be confused 
though, classloaders often are too..  JAR Hell, my my.
;-)


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


Re: classloaders ?

Posted by David Smith <dn...@cornell.edu>.
André Warnier wrote:
> Ken Bowen wrote:
>> I think  http://en.wikipedia.org/wiki/Java_Classloader   was intended
>> -- a reasonable starting point, with further references.
>>
> Thanks all. That was a good starting point.
> Still not wanting to delve too deep into internals, but having read this:
> http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html
> and this:
> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
> and quoting from a previous post on this list :
> "The servlet spec states that jars are to be placed in WEB-INF/lib, so
> that's what Tomcat implements; if the developer wants something beyond
> that, a custom classloader is what's needed."
>
> Now, if I wanted to do as suggested, so as to give "my webapp" a
> classloader that will first look in some directory of my choice, prior
> to looking into all the normal places, how would I, generally
> speaking, go about it ?
>
> I would (I guess) first attempt to locate the basic webapp classloader
> class source of what Tomcat uses as a generic webapp classloader; then
> I would either extend it, or make my own parallel version and compile
> it into a .class file.
> Then where would I put this .class file so that Tomcat notices and
> uses my classloader for my webapp, rather than using its own ?
> Putting my classloader class in the WEB-INF/classes of my webapp
> sounds a bit like a circular argument, no ?
> On the other hand, putting it in some area of the Tomcat common lib
> would make it be picked for all webapps, which is not what I want
> either.  So how does that part work ? (very generically, I am not
> really going to write my own classloader yet).
>
>
>

This has been discussed on the list before, but not in a while... 
Taking a quick look at Google w/ the phrase "tomcat custom classloader",
I found
http://www.nabble.com/Adding-custom-class-loader-to-webapp---td20555683.html
which at least offers hints on how to do it w/ tomcat 6.

I'm sure there are other search results in that list which offer more help.

--David




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


Re: classloaders ?

Posted by André Warnier <aw...@ice-sa.com>.
Caldarale, Charles R wrote:
> 
> The custom classloader is specified via a <Loader> element inside your webapp's <Context> element:
> http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html
> 
That does shed light on the matter.  Clever, these Tomcat guys.

May I respectfully suggest that a link to the above page would probably 
do wonders as a complement inside this page :
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

There is already a link in the other direction.

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


RE: classloaders ?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: classloaders ?
>
> I would (I guess) first attempt to locate the basic
> webapp classloader class source of what Tomcat uses
> as a generic webapp classloader; then I would either
> extend it, or make my own parallel version and compile
> it into a .class file.

There's another approach, semi-supported by Tomcat, as noted in this thread:
http://marc.info/?l=tomcat-user&m=119515455807928&w=2

The VirtualWebappLoader supports additional paths beyond WEB-INF/lib and WEB-INF/classes; however, since it's undocumented and Tomcat-specific, I'm a bit hesitant to suggest it for production environments.

> Then where would I put this .class file so that Tomcat
> notices and uses my classloader for my webapp, rather
> than using its own ?

The custom classloader is specified via a <Loader> element inside your webapp's <Context> element:
http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


Re: classloaders ?

Posted by André Warnier <aw...@ice-sa.com>.
Ken Bowen wrote:
> I think  http://en.wikipedia.org/wiki/Java_Classloader   was intended -- 
> a reasonable starting point, with further references.
> 
Thanks all. That was a good starting point.
Still not wanting to delve too deep into internals, but having read this:
http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html
and this:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
and quoting from a previous post on this list :
"The servlet spec states that jars are to be placed in WEB-INF/lib, so 
that's what Tomcat implements; if the developer wants something beyond 
that, a custom classloader is what's needed."

Now, if I wanted to do as suggested, so as to give "my webapp" a 
classloader that will first look in some directory of my choice, prior 
to looking into all the normal places, how would I, generally speaking, 
go about it ?

I would (I guess) first attempt to locate the basic webapp classloader 
class source of what Tomcat uses as a generic webapp classloader; then I 
would either extend it, or make my own parallel version and compile it 
into a .class file.
Then where would I put this .class file so that Tomcat notices and uses 
my classloader for my webapp, rather than using its own ?
Putting my classloader class in the WEB-INF/classes of my webapp sounds 
a bit like a circular argument, no ?
On the other hand, putting it in some area of the Tomcat common lib 
would make it be picked for all webapps, which is not what I want 
either.  So how does that part work ? (very generically, I am not really 
going to write my own classloader yet).






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


Re: classloaders ?

Posted by Ken Bowen <kb...@als.com>.
I think  http://en.wikipedia.org/wiki/Java_Classloader   was intended  
-- a reasonable starting point, with further references.

On Feb 27, 2009, at 1:06 PM, Youssef Mohammed wrote:

> http://en.wikipedia.org/wiki/Java_Classloadercheck the references  
> over there
> ...
>
> Regards, Youssef
>
>
> On Fri, Feb 27, 2009 at 7:56 PM, André Warnier <aw...@ice-sa.com> wrote:
>
>> Hi.
>>
>> I am a superficial browser on this list and tend not to delve to  
>> deep into
>> Java intricacies.  But when a term consistently shows up which I do  
>> not
>> understand, I try to at least learn enough about it to be able to  
>> reassure
>> my customers.
>>
>> Classloader is now such a term.
>>
>> I gather it is something that the JVM calls when it's missing a  
>> class, to
>> go hunt it down along a logic all its own, and kind of bring it into
>> service. I also gather that it's rather bad to get one's classloader
>> confused by setting CLASSPATHs and the like. And I gather that you  
>> can
>> either have your very own, or rely on Tomcat (?) to provide a  
>> standard one.
>> I haven't a clue however if this is something Tomcat-specific,
>> Java-generic, or in-between.
>>
>> Since I doubt that the above is all there is to say about it, could  
>> someone
>> thus be as kind as to point me to an explanation/tutorial about  
>> classloaders
>> ?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>


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


Re: classloaders ?

Posted by Youssef Mohammed <yo...@gmail.com>.
http://en.wikipedia.org/wiki/Java_Classloadercheck the references over there
...

Regards, Youssef


On Fri, Feb 27, 2009 at 7:56 PM, André Warnier <aw...@ice-sa.com> wrote:

> Hi.
>
> I am a superficial browser on this list and tend not to delve to deep into
> Java intricacies.  But when a term consistently shows up which I do not
> understand, I try to at least learn enough about it to be able to reassure
> my customers.
>
> Classloader is now such a term.
>
> I gather it is something that the JVM calls when it's missing a class, to
> go hunt it down along a logic all its own, and kind of bring it into
> service. I also gather that it's rather bad to get one's classloader
> confused by setting CLASSPATHs and the like. And I gather that you can
> either have your very own, or rely on Tomcat (?) to provide a standard one.
>  I haven't a clue however if this is something Tomcat-specific,
> Java-generic, or in-between.
>
> Since I doubt that the above is all there is to say about it, could someone
> thus be as kind as to point me to an explanation/tutorial about classloaders
> ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: classloaders ?

Posted by "Anthony J. Biacco" <ab...@formatdynamics.com>.
it's a Java/JVM based concept, but understand that Tomcat itself is running in the JVM, so classloading can be relative to tomcat, or whatever you have running in the JVM. For example, the concept of servlets in tomcat are actually the JVM classloader loading a GenericServlet or HttpServlet class, and then instantiating and initializing it.
 
-Tony

 
________________________________

From: André Warnier [mailto:aw@ice-sa.com]
Sent: Fri 27/02/2009 10:56
To: Tomcat Users List
Subject: classloaders ?



Hi.

I am a superficial browser on this list and tend not to delve to deep
into Java intricacies.  But when a term consistently shows up which I do
not understand, I try to at least learn enough about it to be able to
reassure my customers.

Classloader is now such a term.

I gather it is something that the JVM calls when it's missing a class,
to go hunt it down along a logic all its own, and kind of bring it into
service. I also gather that it's rather bad to get one's classloader
confused by setting CLASSPATHs and the like. And I gather that you can
either have your very own, or rely on Tomcat (?) to provide a standard
one.  I haven't a clue however if this is something Tomcat-specific,
Java-generic, or in-between.

Since I doubt that the above is all there is to say about it, could
someone thus be as kind as to point me to an explanation/tutorial about
classloaders ?

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