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 16:31:54 UTC

Patch for Context Class Loader problems (was Re: Fresh CVS checkout - AdminClient list fails)

Sam, Team,

Found the source of my problems and a FIX. Tomcat 3.2.3 and some of the old servlet engines don't
set the context class loader at at all. This patch has been in Cocoon2 code for a long time now
and has been tested extensively in various JDK's and Servlet Engines. Basically the patch is very
simple: 

--------------------------------------- CUT HERE ----------------------------------------------
Index: java/src/org/apache/axis/transport/http/AxisServlet.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
retrieving revision 1.49
diff -u -r1.49 AxisServlet.java
--- java/src/org/apache/axis/transport/http/AxisServlet.java	2001/10/03 15:30:07	1.49
+++ java/src/org/apache/axis/transport/http/AxisServlet.java	2001/10/04 14:18:31
@@ -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();
 
--------------------------------------- CUT HERE ----------------------------------------------

Thanks,
dims

PS: The patch was previously posted by Berin and ignored by ALL :) See
http://marc.theaimsgroup.com/?l=axis-dev&m=100150847909038&w=2


--- Davanum Srinivas <di...@yahoo.com> wrote:
> Sam, Team,
> 
> After some trial and error i found that I have no problems under Tomcat3.3-dev (latest snapshot)
> or Tomcat 4.0. 
> 
> My problem is under Tomcat 3.2.3. The problem is like this:
> 
> - Trying Tomcat3.2.3 Out-Of-The-Box - It has jaxp.jar and parser.jar by default. So when i hit
> the
> http://localhost:8080/axis/servlet/AdminServlet URL, i get the following Stack Trace
> java.lang.NoClassDefFoundError: org/xml/sax/Attributes
> 	at org.apache.axis.AxisEngine.(AxisEngine.java:103)
> 	at org.apache.axis.server.AxisServer.(AxisServer.java:93)
> 	at org.apache.axis.transport.http.AdminServlet.getEngine(AdminServlet.java:85)
> 	at org.apache.axis.transport.http.AdminServlet.doGet(AdminServlet.java:94)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
> 	at org.apache.tomcat.core.Handler.service(Handler.java:287)
> 	at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> 	at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
> 	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
> 	at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
> 	at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> 	at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
> 	at java.lang.Thread.run(Thread.java:484)
> 
> - Next Step, i replace jaxp.jar and parser.jar with xerces_1_4_3.jar and re-start tomcat and try
> start/stop the server at http://localhost:8080/axis/servlet/AdminServlet URL, No problems doing
> that. But then i try AdminClient on the commandline and hit the problem.
> 
> D:\JAKARTA\xml-axis\java>java org.apache.axis.client.AdminClient list
> Doing a list
> <ns1:Fault xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
>    <ns1:faultcode xmlns:ns4="http://xml.apache.org/axis/">ns4:Server.NoService</ns1:faultcode>
>    <ns1:faultstring>The Axis engine couldn't find a target service to invoke! targetService is
> AdminService</ns1:faultstring>
>   </ns1:Fault>
> 
> Due to reasons beyond my control at this time, I need to stick with Tomcat3.2.3. So can someone
> help?
> 
> Thanks,
> dims
> 
> --- Sam Ruby <ru...@us.ibm.com> wrote:
> > I just refreshed http://nagoya.apache.org:5049/ with the latest Axis code,
> > and successfully deployed bidbuy, stock, and echo.
> > 
> > - Sam Ruby
> > 
> 
> 
> =====
> 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


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

Re: Patch for Context Class Loader problems (was Re: Fresh CVS checkout - AdminClient list fails)

Posted by Davanum Srinivas <di...@yahoo.com>.
Yes, Berin. See the PS Below: I sent a URL with your original message.
-- dims

--- Berin Loritsch <bl...@apache.org> wrote:
> Didn't I post this SAME patch a week or two ago?
> 
> Davanum Srinivas wrote:
> > 
> > Sam, Team,
> > 
> > Found the source of my problems and a FIX. Tomcat 3.2.3 and some of the old servlet engines
> don't
> > set the context class loader at at all. This patch has been in Cocoon2 code for a long time
> now
> > and has been tested extensively in various JDK's and Servlet Engines. Basically the patch is
> very
> > simple:
> > 
> > --------------------------------------- CUT HERE
> ----------------------------------------------
> > Index: java/src/org/apache/axis/transport/http/AxisServlet.java
> > ===================================================================
> > RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
> > retrieving revision 1.49
> > diff -u -r1.49 AxisServlet.java
> > --- java/src/org/apache/axis/transport/http/AxisServlet.java    2001/10/03 15:30:07     1.49
> > +++ java/src/org/apache/axis/transport/http/AxisServlet.java    2001/10/04 14:18:31
> > @@ -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();
> > 
> > --------------------------------------- CUT HERE
> ----------------------------------------------
> > 
> > Thanks,
> > dims
> > 
> > PS: The patch was previously posted by Berin and ignored by ALL :) See
> > http://marc.theaimsgroup.com/?l=axis-dev&m=100150847909038&w=2
> > 
> > --- Davanum Srinivas <di...@yahoo.com> wrote:
> > > Sam, Team,
> > >
> > > After some trial and error i found that I have no problems under Tomcat3.3-dev (latest
> snapshot)
> > > or Tomcat 4.0.
> > >
> > > My problem is under Tomcat 3.2.3. The problem is like this:
> > >
> > > - Trying Tomcat3.2.3 Out-Of-The-Box - It has jaxp.jar and parser.jar by default. So when i
> hit
> > > the
> > > http://localhost:8080/axis/servlet/AdminServlet URL, i get the following Stack Trace
> > > java.lang.NoClassDefFoundError: org/xml/sax/Attributes
> > >       at org.apache.axis.AxisEngine.(AxisEngine.java:103)
> > >       at org.apache.axis.server.AxisServer.(AxisServer.java:93)
> > >       at org.apache.axis.transport.http.AdminServlet.getEngine(AdminServlet.java:85)
> > >       at org.apache.axis.transport.http.AdminServlet.doGet(AdminServlet.java:94)
> > >       at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> > >       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > >       at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
> > >       at org.apache.tomcat.core.Handler.service(Handler.java:287)
> > >       at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> > >       at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
> > >       at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
> > >       at
> > >
> >
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
> > >       at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> > >       at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
> > >       at java.lang.Thread.run(Thread.java:484)
> > >
> > > - Next Step, i replace jaxp.jar and parser.jar with xerces_1_4_3.jar and re-start tomcat and
> try
> > > start/stop the server at http://localhost:8080/axis/servlet/AdminServlet URL, No problems
> doing
> > > that. But then i try AdminClient on the commandline and hit the problem.
> > >
> > > D:\JAKARTA\xml-axis\java>java org.apache.axis.client.AdminClient list
> > > Doing a list
> > > <ns1:Fault xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
> > >    <ns1:faultcode
> xmlns:ns4="http://xml.apache.org/axis/">ns4:Server.NoService</ns1:faultcode>
> > >    <ns1:faultstring>The Axis engine couldn't find a target service to invoke! targetService
> is
> > > AdminService</ns1:faultstring>
> > >   </ns1:Fault>
> > >
> > > Due to reasons beyond my control at this time, I need to stick with Tomcat3.2.3. So can
> someone
> > > help?
> > >
> > > Thanks,
> > > dims
> > >
> > > --- Sam Ruby <ru...@us.ibm.com> wrote:
> > > > I just refreshed http://nagoya.apache.org:5049/ with the latest Axis code,
> > > > and successfully deployed bidbuy, stock, and echo.
> > > >
> > > > - Sam Ruby
> > > >
> > >
> > >
> > > =====
> > > 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
> > 
> > =====
> > 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


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

Re: Patch for Context Class Loader problems (was Re: Fresh CVS checkout - AdminClient list fails)

Posted by Berin Loritsch <bl...@apache.org>.
Didn't I post this SAME patch a week or two ago?

Davanum Srinivas wrote:
> 
> Sam, Team,
> 
> Found the source of my problems and a FIX. Tomcat 3.2.3 and some of the old servlet engines don't
> set the context class loader at at all. This patch has been in Cocoon2 code for a long time now
> and has been tested extensively in various JDK's and Servlet Engines. Basically the patch is very
> simple:
> 
> --------------------------------------- CUT HERE ----------------------------------------------
> Index: java/src/org/apache/axis/transport/http/AxisServlet.java
> ===================================================================
> RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
> retrieving revision 1.49
> diff -u -r1.49 AxisServlet.java
> --- java/src/org/apache/axis/transport/http/AxisServlet.java    2001/10/03 15:30:07     1.49
> +++ java/src/org/apache/axis/transport/http/AxisServlet.java    2001/10/04 14:18:31
> @@ -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();
> 
> --------------------------------------- CUT HERE ----------------------------------------------
> 
> Thanks,
> dims
> 
> PS: The patch was previously posted by Berin and ignored by ALL :) See
> http://marc.theaimsgroup.com/?l=axis-dev&m=100150847909038&w=2
> 
> --- Davanum Srinivas <di...@yahoo.com> wrote:
> > Sam, Team,
> >
> > After some trial and error i found that I have no problems under Tomcat3.3-dev (latest snapshot)
> > or Tomcat 4.0.
> >
> > My problem is under Tomcat 3.2.3. The problem is like this:
> >
> > - Trying Tomcat3.2.3 Out-Of-The-Box - It has jaxp.jar and parser.jar by default. So when i hit
> > the
> > http://localhost:8080/axis/servlet/AdminServlet URL, i get the following Stack Trace
> > java.lang.NoClassDefFoundError: org/xml/sax/Attributes
> >       at org.apache.axis.AxisEngine.(AxisEngine.java:103)
> >       at org.apache.axis.server.AxisServer.(AxisServer.java:93)
> >       at org.apache.axis.transport.http.AdminServlet.getEngine(AdminServlet.java:85)
> >       at org.apache.axis.transport.http.AdminServlet.doGet(AdminServlet.java:94)
> >       at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> >       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >       at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
> >       at org.apache.tomcat.core.Handler.service(Handler.java:287)
> >       at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> >       at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
> >       at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
> >       at
> >
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
> >       at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> >       at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
> >       at java.lang.Thread.run(Thread.java:484)
> >
> > - Next Step, i replace jaxp.jar and parser.jar with xerces_1_4_3.jar and re-start tomcat and try
> > start/stop the server at http://localhost:8080/axis/servlet/AdminServlet URL, No problems doing
> > that. But then i try AdminClient on the commandline and hit the problem.
> >
> > D:\JAKARTA\xml-axis\java>java org.apache.axis.client.AdminClient list
> > Doing a list
> > <ns1:Fault xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
> >    <ns1:faultcode xmlns:ns4="http://xml.apache.org/axis/">ns4:Server.NoService</ns1:faultcode>
> >    <ns1:faultstring>The Axis engine couldn't find a target service to invoke! targetService is
> > AdminService</ns1:faultstring>
> >   </ns1:Fault>
> >
> > Due to reasons beyond my control at this time, I need to stick with Tomcat3.2.3. So can someone
> > help?
> >
> > Thanks,
> > dims
> >
> > --- Sam Ruby <ru...@us.ibm.com> wrote:
> > > I just refreshed http://nagoya.apache.org:5049/ with the latest Axis code,
> > > and successfully deployed bidbuy, stock, and echo.
> > >
> > > - Sam Ruby
> > >
> >
> >
> > =====
> > 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
> 
> =====
> 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