You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Will England <wi...@mylanders.com> on 2001/07/19 16:49:17 UTC

[3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Greetings!

Over on tomcat-users, theres been a discussion on JSP's finding the
WEB-INF/classes directory when compiling.  They can't.  From searches, I
understand this issue has come up before in regards to the Coocon project.

The root problem is that Jasper cannot find classes located in
WEB-INF/classes of the web application that the JSP's belong to.  This
occurs when a JSP is either first deployed or the TOMCAT_HOME/work
directory is cleared, requiring a recompile of the JSP's.

The system is Tomcat 3.2 under Apache with mod_jk, running on SunOS 2.7
with JDK 1.2.

The code in question is coming from a production Tomcat 3.1 system.

I cannot add the WEB-INF/classes directory to my classpath.  This will
break several other parts of the system.

What is the problem with Jasper reading WEB-INF/classes?

I understand the the Coocon users found some kind of workaround, but I
have been unable to find it.

Thank you for any pointers or tips!

Will


-- 
  /~>'find `funny quote`': Command not found; humor not installed.  
  1986 Concours 72,xxx  1982 Maxim 12,xxx (For Sale!) CDA #00046
  Overland Park, KS     will@mylanders.com     PCS: 316-371-FOAD
                    http://will.mylanders.com/


Re: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Posted by David Haraburda <da...@haraburda.com>.
Oops,

That's right, you can read any file you want from WEB-INF/classes using
getResource() (which is probably what you are doing) -- that is implemented
correctly in AdaptiveClassLoader.  If you want to find all resources of a
specified name (for example, you have a properties file of the same name at
the web-application level and the system level, and you want to concatenate
values from both places together), the ClassLoader class provides a
getResources() method.  (This method in turn calls findResources which is
supposed to be implemented in all subclasses of ClassLoader, but isn't for
AdaptiveClassLoader)

I'm glad to know that fixed it.

David

Will England wrote:

> On Fri, 20 Jul 2001, David Haraburda wrote:
>
> > Have you tried using the Jdk12Interceptor?  That fixed class loading
> > problems for me.  In your server.xml do:
> >
> > <RequestInterceptor
> > className="org.apache.tomcat.request.Jdk12Interceptor"/>
>
> Got that, and it fixed the finding of my .conf files that I store in
> WEB-INF/classes.  I can now read any text file I want from WEB-INF/classes
> from a servlet.
>
> > Note this will only fix the loading of CLASSES... if you have resources
> > in your WEB-INF/classes directory, such as .properties files, that the
> > ClassLoader is supposed to pick up, this will not happen.  I submitted a
> > patch for this to the mailing list last night, but haven't heard
> > anything from a developer/committer yet.
>
> Odd.  Worked well for me.  As soon as the admin gets the box back up, I'll
> drop you a copy of my server.xml and the code I use to read a text file.
>
> > A good way to see what ClassLoader is being used is by sticking in a
> > System.out.println( "CL: " +
> > Thread.currentThread().getContextClassLoader().toString() );
> >
> > If it says com.sun.misc.something (I forget the package name), you are
> > using the System classloader... if it says AdaptiveClassLoader, you are
> > using the Tomcat one which knows about stuff in the WEB-INF directory.
>
> Nice tip - I'll try that!
>
> Will


Re: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Posted by Will England <wi...@mylanders.com>.
On Fri, 20 Jul 2001, David Haraburda wrote:

> Have you tried using the Jdk12Interceptor?  That fixed class loading
> problems for me.  In your server.xml do:
> 
> <RequestInterceptor
> className="org.apache.tomcat.request.Jdk12Interceptor"/>

Got that, and it fixed the finding of my .conf files that I store in
WEB-INF/classes.  I can now read any text file I want from WEB-INF/classes
from a servlet.

> Note this will only fix the loading of CLASSES... if you have resources
> in your WEB-INF/classes directory, such as .properties files, that the
> ClassLoader is supposed to pick up, this will not happen.  I submitted a
> patch for this to the mailing list last night, but haven't heard
> anything from a developer/committer yet.

Odd.  Worked well for me.  As soon as the admin gets the box back up, I'll
drop you a copy of my server.xml and the code I use to read a text file.

> A good way to see what ClassLoader is being used is by sticking in a
> System.out.println( "CL: " +
> Thread.currentThread().getContextClassLoader().toString() );
> 
> If it says com.sun.misc.something (I forget the package name), you are
> using the System classloader... if it says AdaptiveClassLoader, you are
> using the Tomcat one which knows about stuff in the WEB-INF directory.


Nice tip - I'll try that!

Will


Re: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Posted by David Haraburda <da...@haraburda.com>.
Hi,

I too missed the original message, but have been dealing with these
problems myself.

Have you tried using the Jdk12Interceptor?  That fixed class loading
problems for me.  In your server.xml do:

<RequestInterceptor
className="org.apache.tomcat.request.Jdk12Interceptor"/>

There are some weird classloader issues w/ Java 2 that this fixes.

Note this will only fix the loading of CLASSES... if you have resources
in your WEB-INF/classes directory, such as .properties files, that the
ClassLoader is supposed to pick up, this will not happen.  I submitted a
patch for this to the mailing list last night, but haven't heard
anything from a developer/committer yet.

A good way to see what ClassLoader is being used is by sticking in a
System.out.println( "CL: " +
Thread.currentThread().getContextClassLoader().toString() );

If it says com.sun.misc.something (I forget the package name), you are
using the System classloader... if it says AdaptiveClassLoader, you are
using the Tomcat one which knows about stuff in the WEB-INF directory.

David

Will England wrote:
> 
> On Thu, 19 Jul 2001, David Rees wrote:
> 
> > (Sorry about the double-qoute, I missed the original message)
> >
> >
> > I have noticed the same problem while doing some development using
> > Tomcat 3.2.[23].  I worked around it by making sure that I unset the
> > classpath before calling startup.sh, then things seemed to work properly
> > and classes were found as expected.
> 
> Tried that.  Tried hard-coding the classpath.  If the web applications
> WEB-INF/classes directory was in the system classpath, it compiles.  If it
> is not in the system classpath, the JSP's do not compile.
> 
> So, why does Jasper not know about the web-application classpath?
> 
> Will

-- 
David Haraburda - david@haraburda.com
Everest - Helping You Manage Outsourcing
972-980-0013 x736

Re: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Posted by Will England <wi...@mylanders.com>.
On Thu, 19 Jul 2001, David Rees wrote:

> (Sorry about the double-qoute, I missed the original message)
> 
> 
> I have noticed the same problem while doing some development using
> Tomcat 3.2.[23].  I worked around it by making sure that I unset the
> classpath before calling startup.sh, then things seemed to work properly
> and classes were found as expected.

Tried that.  Tried hard-coding the classpath.  If the web applications
WEB-INF/classes directory was in the system classpath, it compiles.  If it
is not in the system classpath, the JSP's do not compile.  

So, why does Jasper not know about the web-application classpath?  

Will


Re: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Posted by David Rees <db...@greenhydrant.com>.
(Sorry about the double-qoute, I missed the original message)

> > -----Original Message-----
> > From: Will England [mailto:will@mylanders.com]
> > Sent: Thursday, July 19, 2001 10:49 AM
> > To: tomcat-dev@jakarta.apache.org
> > Subject: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes
> >
> >
> > Greetings!
> >
> > Over on tomcat-users, theres been a discussion on JSP's finding the
> > WEB-INF/classes directory when compiling.  They can't.  From searches, I
> > understand this issue has come up before in regards to the Coocon project.
> >
> > The root problem is that Jasper cannot find classes located in
> > WEB-INF/classes of the web application that the JSP's belong to.  This
> > occurs when a JSP is either first deployed or the TOMCAT_HOME/work
> > directory is cleared, requiring a recompile of the JSP's.
> >
> > The system is Tomcat 3.2 under Apache with mod_jk, running on SunOS 2.7
> > with JDK 1.2.

I have noticed the same problem while doing some development using
Tomcat 3.2.[23].  I worked around it by making sure that I unset the
classpath before calling startup.sh, then things seemed to work properly
and classes were found as expected.

It seems that certain combinations of classes in different ares
(CLASSPATH, WEB-INF/lib, or other) will break things, but I haven't
pinned it down, so it could simply be user stupidity.

-Dave

RE: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes

Posted by "Rob S." <rs...@home.com>.
I guess I don't follow, cuz I use this functionality of Tomcat every single
day.

Whether or not its under Apache shouldn't matter.

- r

> -----Original Message-----
> From: Will England [mailto:will@mylanders.com]
> Sent: Thursday, July 19, 2001 10:49 AM
> To: tomcat-dev@jakarta.apache.org
> Subject: [3.2] JSP Compiling Classpath issues -- finding WEB-INF/classes
>
>
> Greetings!
>
> Over on tomcat-users, theres been a discussion on JSP's finding the
> WEB-INF/classes directory when compiling.  They can't.  From searches, I
> understand this issue has come up before in regards to the Coocon project.
>
> The root problem is that Jasper cannot find classes located in
> WEB-INF/classes of the web application that the JSP's belong to.  This
> occurs when a JSP is either first deployed or the TOMCAT_HOME/work
> directory is cleared, requiring a recompile of the JSP's.
>
> The system is Tomcat 3.2 under Apache with mod_jk, running on SunOS 2.7
> with JDK 1.2.
>
> The code in question is coming from a production Tomcat 3.1 system.
>
> I cannot add the WEB-INF/classes directory to my classpath.  This will
> break several other parts of the system.
>
> What is the problem with Jasper reading WEB-INF/classes?
>
> I understand the the Coocon users found some kind of workaround, but I
> have been unable to find it.
>
> Thank you for any pointers or tips!
>
> Will
>
>
> --
>   /~>'find `funny quote`': Command not found; humor not installed.
>   1986 Concours 72,xxx  1982 Maxim 12,xxx (For Sale!) CDA #00046
>   Overland Park, KS     will@mylanders.com     PCS: 316-371-FOAD
>                     http://will.mylanders.com/
>
>