tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Cannot find my JavaBeans
Date Thu, 19 Jul 2001 23:31:18 GMT


On Thu, 19 Jul 2001, John Baker wrote:

> On Thursday 19 July 2001 15:43 pm, you wrote:
> > > -----Original Message-----
> >
> > > MyThread x = new MyThraad();
> > > x.run();
> > >
> > > calls the run method (containing the class that has problems
> > > being created)
> > > within the current Thread, ie no new Thread is started, This
> > > is when the
> > > problem 'goes away'.
> >
> > Ok, I have written threads in C,C++(not in Java) but I am missing something
> > thats seems very basic here. so what you are saying is that run() is not
> > really creating a new thread, but really just creating an object named
> > 'MyThread' that happens to have a run() method? This would indicate that it
> > is not a new thread, but just a method(run()) from another class(MyThread)
> > that is called within the same thread.
> 
> Yes. I deliberately did this to try and work out what was going on. I agree 
> with your ClassLoader explanation. I'll look into it.
> 
> But, when TC calls my ServletContextListener (this was defined as a listener 
> within the web.xml) it *should* provide the ClassLoade for that application. 
> My listener was part of an application and giving it a different ClassLoader 
> is wrong. In my humble opinion :-)
> 

A recent clarification in the J2EE 1.3 spec (and therefore applies to
servlet 2.3 containers embedded in such servers) is that the web app class
loader must be provided as the value of the context class loader
(Thread.currentThread().getContextClassLoader()) to all method calls on a
request processing thread.  Note that this is *not* necessarily the class
loader used to load the class you are currently running, which could have
itself been loaded from a parent classloader.

On the general topic of threads in servlet containers, you can *not* rely
on an arbitrary thread you have created having access to the web app class
loader unless you take steps to save it.  The thread's context class
loader value is only defined for the request processing threads created by
the container itself -- not your own threads.

> 
> John
> 

Craig McClanahan



Mime
View raw message