You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Davanum Srinivas <di...@yahoo.com> on 2001/10/04 18:22:34 UTC
Re: AW: Patch for Context Class Loader problems (was Re: Fresh CVS ch eckout - AdminClient list fails)
Glen, Dr. Jung,
I looked into the patches. I don't think my patch will interfere with Dr Jung's code at all. I
again re-state the problem. Under some of the old Servlet Engines like Tomcat 3.2.3 if you print
the Thread.currentThread().getContextClassLoader() in AxisServlet's init function. It will print
"sun.misc.Launcher$AppClassLoader@71732b" which is the system default class (see
http://www.jguru.com/faq/view.jsp?EID=4318). This is because the Servlet Engine does not set the
Context Class Loader at all. This is exactly what my patch does.
Now if the patch that i sent leads to problems, i promise to send in patches to fix them or will
ask you guys to comment the line out........This should not be that difficult.
Thanks,
dims
--- "Jung , Dr. Christoph" <ch...@infor.de> wrote:
> -----Urspr�ngliche Nachricht-----
> >Von: Davanum Srinivas [mailto:dims@yahoo.com]
> >Gesendet: Donnerstag, 4. Oktober 2001 17:25
> >An: Tom Jordahl
> >Cc: axis-dev@xml.apache.org
> >Betreff: RE: Patch for Context Class Loader problems (was Re: Fresh CVS
> >ch eckout - AdminClient list fails)
>
> >No Tom. Dr. J's comment was that there should be a better class-loading
> mechanism for all the
> >things that need to be picked up at runtime that are not available to the
> class loader that loaded
> >the Axis Servlet. I absolutely agree with this. But that does not mean that
> my fix will stop us
> >from implenting such a mechanism.
>
> I absolutely agree, my comment was just to extend a bit on the important
> classloader issue. I
> didn�t want to confuse, sorry.
>
> >Talking theoretical is great!!! We have a real-world project that has to be
> implemented on some
> >Servlet Engines in a production environment for which we need a FIX
> NOW!!!!. After all you can
> >comment out the single line of code ANYTIME!!!!
>
> Attached is my work-around to that problem. The diff refactors
> org.apache.axis.transports.http.AxisServlet
> such that subclasses (org.jboss.net.axis.AxisServiceServlet) can produce
> different MessageContexts (here
> org.jboss.net.axis.ClassLoaderAwareMessageContext).
>
> The org.jboss.net.axis.ClassLoaderAwareMessageContext in conjunction with
> the org.jboss.net.axis.ClassLoaderAwareAxisServer is able to reestablish the
> right
> service classloader while doing a setTargetService(String serviceName).
>
> Maybe that also solves the problem of Mr. Srinivas? As said before, having
> the deployment classloader being associated with every deployable item for
> further resolution would IMHO be a better design.
>
> Best,
> CGJ
>
>
>
>
>
> ATTACHMENT part 2 application/octet-stream name=AxisServlet.diff
> ATTACHMENT part 3 application/octet-stream name=ClassLoaderAwareMessageContext.java
> ATTACHMENT part 4 application/octet-stream name=ClassLoaderAwareAxisServer.java
> ATTACHMENT part 5 application/octet-stream name=AxisServiceServlet.java
=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI
__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1
Updated Patch for Context Class Loader problems
Posted by Davanum Srinivas <di...@yahoo.com>.
Hi Team,
Here's an updated patch for the Class Loader problems (after a brief chat on IRC with Glen & Sam).
Thanks,
dims
--------------------------------------- CUT HERE
-------------------------------------------------Index: AxisServlet.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
retrieving revision 1.50
diff -u -r1.50 AxisServlet.java
--- AxisServlet.java 2001/10/04 14:36:50 1.50
+++ AxisServlet.java 2001/10/04 16:35:28
@@ -96,6 +96,15 @@
private static final String AXIS_ENGINE = "AxisEngine" ;
public void init() {
+ /*
+ * HACK: Some Servlet Engines have bad Context Class Loader (Like Tomcat3.2.3)
+ * Since by definition, The Class Loader that loaded this Servlet should be
+ * the Context Class Loader, We set the Context Class Loader explicity.
+ */
+ try {
+ Thread.currentThread().setContextClassLoader(AxisServlet.class.getClassLoader());
+ } catch (Exception e){}
+
String param = getInitParameter("transport.name");
ServletContext context = getServletConfig().getServletContext();
@@ -108,6 +117,20 @@
if ((param != null) && (param.equalsIgnoreCase("true"))) {
securityProvider = new ServletSecurityProvider();
}
+ }
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws ServletException, IOException {
+ /*
+ * HACK: Some Servlet Engines have bad Context Class Loader (Like Tomcat3.2.3)
+ * Since by definition, The Class Loader that loaded this Servlet should be
+ * the Context Class Loader, We set the Context Class Loader explicity.
+ */
+ try {
+ Thread.currentThread().setContextClassLoader(AxisServlet.class.getClassLoader());
+ } catch (Exception e){}
+
+ super.service(req,res);
}
public AxisServer getEngine() {
--------------------------------------- CUT HERE -------------------------------------------------
=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI
__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1