Title: RE: MIssing Classes - WHAT is the answer? :-)

Ok, I'm not a developer, and I am using TC 3.2.1, not TC4, but a quick look at the ServletContextListener and I have some comments based upon what I know about TC 3.2.1.

see below.

> -----Original Message-----
> From: John Baker [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 19, 2001 4:40 AM
> To: [EMAIL PROTECTED]
> Subject: MIssing Classes - WHAT is the answer? :-)
>
>
> Right! Enough of this! I'm confused!
>
> Obviously there is confusion to why tomcat seems to not find
> classes that are
> clearly located in the WEB-INF/classes directory (in package
> names, or
> whatever) or in a jar. This appears to be a bug with the
> ClassLoad that is in
> place, as has been pointed out to me.
>
I don't think this is a bug, but rather how Tomcat is implemented. 'Tomcat'(TC base code) can't find your files because its classloader doesn't know about the web-inf/classes. Your webapp can find them because it has its own (different than Tomcat's base code) class loader that knows about web-inf/classes. Therefore when you create a thread from SessionContextListener(created by Tomcat base code, not the context) it will inherit the classloader from tomcat's base code, not the classloader used by sessions.

You may want to see if you can get the classloader from the context(in 3.2.1, it is stored in the context object) and set your new thread to use that classloader, making the classloader parent your current classloader.


> I've read about dynamic compilation and class loading
> problems. Well I've had
> no problems with my jsp pages finding classes in jars or the classes
> directory.
>
> I don't know why is responsible for this part of tomcat, or
> whether this is
> the right list to post to, but wouldn't it be a good idea for
> someone who
> knows what they are talking about (ie whoever wrote this part
> of Tomcat!) to
> write a mail stating exactly how it should work, and what
> known problems
> there are. If there are known problems, are they being
> addressed? It's
> difficult to tell people (management) that Tomcat is the
> solution if there is
> no gaurantee that this is being looked at. However as I love
> tomcat and open
> source, I'd rather use it than some offering from another company :)
>
> Clearly, if there are classes in the WEB-INF/classes, or
> within a jar in
> WEB-INF/lib, then they should be found from Jsp pages or any
> object that sits
> in the session. My problem, as I've pointed out before, is
> the ClassLoader
> that gets given to a Thread I try and start from a
> ServletContextListener. Ie

I beleive that the ServletContextListener is not part of a session, but running under Tomcat awaiting events pertaining to a context therefore it does not know about sessions or classloaders that they have implemented.

> a Thread I start to read news when the web application
> starts. Classes are
> just not found. Oddly enough, if I start this same thread
> from the top of a
> Jsp page - it works fine!
>

A JSP is running in the session and its classloader knows about the web-inf/classes.

> So, would someone like to enlighten us all so we can stop
> guessing and
> confusing the issue. There are just too many mails about this
> topic now, and
> it's hard to work out what the correct answer is.
>
>
>
> Cheers
>
>
> John Baker (still sifting through the many many of posts on this ;-)
>
> On Wednesday 18 July 2001 22:50 pm, you wrote:
> > Hmmm.
> >
> > According to Dr. Mel Martinez on the tomcat-dev list,
> Jasper *cannot* see
> > the web-inf/classes part of your web app for compliation. 
> SO, I guess the
> > solution is to pre-compile the JSP's (somehow) and leave
> the compiled
> > .class files in the TOMCAT_HOME/work directory.
> >
> > Then, we're *screwed* if a customer wants to modify one of
> the JSP files
> > on their server.
> >
> > Grrr.
> >
> > Ideas?
> >
> >
> >
> > http://w6.metronet.com/~wjm/tomcat/2001/Mar/msg00696.html
>
> --
> John Baker, BSc CS.
> Java developer, Linux lover.
> I don't wanna rock, DJ.
>

Reply via email to