You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Pat C <pa...@gmail.com> on 2008/03/06 17:25:04 UTC

JSP Classloader issue

Hi,

Similar to how different servlets run in different classloaders scope, 
we have written a web application (WAR File) that runs the applications 
for each customer by creating a classloader per customer within the same 
servlet context.

This means that all the dependent jar files of the project are NOT 
placed under WEB-INF/lib, but instead under another folder where the 
applications can be hot-swapped. While we successfully implemented 
customer specific classloader, we run into problems when the servlet 
forwarded the request to a JSP.

JSP apparently takes the class loader in which the WAR file is running 
and NOT our classloader, inspite of setting 
Thread.getCurrentThread().setContextClassLoader(CustomerSpecificClassLoader) 
in the servlet before the request was forwarded.

I am now stuck after committing so far in the project and now unable to 
find a solution.

Can you please advice me a way out?
Pat

---------------------------------------------------------------------
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: JSP Classloader issue

Posted by Martin Gainty <mg...@hotmail.com>.
Pat-

appears to be a security error
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setContextClas
sLoader(java.lang.ClassLoader)
you'll need to set the runtime permission for the classLoader to execute via
1) make these edits to $CATALINA_HOME/conf/catalina.policy
grant codeBase "file:${catalina.home}/webapps/AppX/-"{
permission java.lang.RuntimePermission "setContextClassLoader";
}

2)restart TC to use the SecurityManager
%CATALINA_HOME%\bin\catalina start -security

3)read the logs to determine the contextClassLoader is in fact being loaded
and executed by catalina..

M-
----- Original Message -----
From: "Pat C" <pa...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Thursday, March 06, 2008 11:25 AM
Subject: JSP Classloader issue


> Hi,
>
> Similar to how different servlets run in different classloaders scope,
> we have written a web application (WAR File) that runs the applications
> for each customer by creating a classloader per customer within the same
> servlet context.
>
> This means that all the dependent jar files of the project are NOT
> placed under WEB-INF/lib, but instead under another folder where the
> applications can be hot-swapped. While we successfully implemented
> customer specific classloader, we run into problems when the servlet
> forwarded the request to a JSP.
>
> JSP apparently takes the class loader in which the WAR file is running
> and NOT our classloader, inspite of setting
>
Thread.getCurrentThread().setContextClassLoader(CustomerSpecificClassLoader)
> in the servlet before the request was forwarded.
>
> I am now stuck after committing so far in the project and now unable to
> find a solution.
>
> Can you please advice me a way out?
> Pat
>
> ---------------------------------------------------------------------
> 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: JSP Classloader issue

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Pat C [mailto:pat.chang1973@gmail.com] 
> Subject: JSP Classloader issue
> 
> Similar to how different servlets run in different 
> classloaders scope, 

Actually, it's different webapps that are handled by separate
classloaders.  All servlets of a given webapp are under the same
classloader.

> we run into problems when the servlet forwarded the
> request to a JSP.

What happens if you pre-compile the JSPs, so they all become servlets
and you can place them in the necessary directories?  See:
http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html#Web%20Applicat
ion%20Compilation

 - 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 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