Howdy,

Thanks for the reply. By looking at the code in
org.apache.commons.logging.LogFactory.findClassLoader() it seems to be doing
what you've suggested. I've found similar messages with this same problem in
the struts-dev list. The subject is 'Problems with 1.1b1'. It seems
Tomcat3.3a is having the same problem. Tomcat4.0.3 works fine.

The suggested workaround was to stick the commons-logging.jar in the
%TOMCAT_HOME%\lib\common folder. I've tried the similar workaround in
JRun3.1 by sticking the jar file in its %JRUN_HOME%\lib\ext folder, but then
I run into the expected problem of cascading ClassNotFoundExceptions for
struts classes...particularly for its MessageResources classes. 

It seems these older servlet engines...may not be fully J2EE compliant when
it comes to providing the correct ClassLoader when loading/initializing a
servlet from preload. I'm guessing the servlet-engine is not setting the
ClassLoader in Thread.setContextClassLoader(ClassLoader) when initializing a
servlet from a preload. If this is the case, do you think if i set the
ClassLoader myself in the ActionServlet's init() method this problem may be
fixed? i.e.

public void init()
{
        
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader(
));
        log = LogFactory.getLog(this.getClass());

        ...
}

-ronel

 
-----Original Message-----
From: Jesse Alexander (KADA 12) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 2:00 AM
To: Struts Users Mailing List
Subject: RE: Cannot preload ActionServlet in JRun3.1using Struts1.1-b1


Hi,

having done some classloading lately... I would say it is a standard issue
with J2EE-compatible servlet-engines.

It depends where you have the struts- and logging-jars. If they are in 
one of the parent-classloader-paths then they cannot load the classes
from WEB-INF/lib (and classes) as long as they use the old
class.forName(class_name) method.

As both libraries that you mention are opensource, why not try to change
the code to use either
class.forName(class_name, true,
Thread.currentThread().getContextClassLoader());
or
Thread.currentThread().getContextClassLoader().loadClass(class_name);

hope this helps
Alexander

-----Original Message-----
From: Ronel Sumibcay [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 26. März 2002 00:32
To: 'Struts Users Mailing List'
Subject: Cannot preload ActionServlet in JRun3.1using Struts1.1-b1


This may be a problem in JRun's web app class loading implementation or in
the commons-logging implementation. The exception occurs if you try to
preload the ActionServlet. But if the ActionServlet is initialized from a
request it is loaded just fine. It looks like the
org.apache.commons.logging.LogFactory.findClassLoader() maybe returning the
wrong ClassLoader when called when an ActionServlet is being preloaded...all
the struts and commons-*.jar files are in the usual web-inf/lib folder.

This is a show stopper for those who are extending ActionServlet to do some
extra initialization which needs to be initialized before anything else. Its
forcing me to go back to a struts nightly build that does not have the
commons-logging implementation. 

If this a bug in org.apache.commons.logging.LogFactory.findClassLoader(),
then would the fix cause changes in struts or would i simply have to get the
latest commons-logging.jar if and when this is addressed?

Thanks.

-ronel

03/25 14:44:34 error (JRun) Could not pre-load servlet: action
[javax.servlet.ServletException: Could not instantiate
org.apache.struts.action.ActionServlet]
[1]org.apache.commons.logging.LogConfigurationException:
java.lang.ClassNotFoundException:
org.apache.commons.logging.impl.LogFactoryImpl
        at
org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:497)
        at
org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381)
        at
org.apache.struts.action.ActionServlet.<init>(ActionServlet.java:331)
        at java.lang.Class.newInstance0(Native Method)
        at java.lang.Class.newInstance(Unknown Source)
        at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(../servlet/JRunSe
rvletLoader.java:197)
        at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(../servlet/JRunSe
rvletLoader.java:161)
        at
allaire.jrun.servlet.JRunServletLoader.loadServlet(../servlet/JRunServletLoa
der.java:149)
        at
allaire.jrun.servlet.JRunSE.getServletReference(../servlet/JRunSE.java:1705)
        at
allaire.jrun.servlet.JRunSE.preloadServlets(../servlet/JRunSE.java:1371)
        at allaire.jrun.servlet.JRunSE.init(../servlet/JRunSE.java:236)
        at allaire.jrun.ServletService.init(../ServletService.java:66)
        at allaire.jrun.ServletService.init(../ServletService.java:31)
        at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(../servlet/JRunSe
rvletLoader.java:203)
        at
allaire.jrun.servlet.JRunSE.initService(../servlet/JRunSE.java:891)
        at
allaire.jrun.servlet.JRunSE.initServices(../servlet/JRunSE.java:858)
        at
allaire.jrun.servlet.JvmContext.initServices(../servlet/JvmContext.java:130)
        at allaire.jrun.servlet.JRunSE.init(../servlet/JRunSE.java:222)
        at
allaire.jrun.servlet.JvmContext.init(../servlet/JvmContext.java:69)
        at allaire.jrun.ServletService.init(../ServletService.java:66)
        at allaire.jrun.ServletService.init(../ServletService.java:31)
        at JRun.main(../../../JRun.java:172)
[0]javax.servlet.ServletException: Could not instantiate
org.apache.struts.action.ActionServlet
        at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(../servlet/JRunSe
rvletLoader.java:209)
        at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(../servlet/JRunSe
rvletLoader.java:161)
        at
allaire.jrun.servlet.JRunServletLoader.loadServlet(../servlet/JRunServletLoa
der.java:149)
        at
allaire.jrun.servlet.JRunSE.getServletReference(../servlet/JRunSE.java:1705)
        at
allaire.jrun.servlet.JRunSE.preloadServlets(../servlet/JRunSE.java:1371)
        at allaire.jrun.servlet.JRunSE.init(../servlet/JRunSE.java:236)
        at allaire.jrun.ServletService.init(../ServletService.java:66)
        at allaire.jrun.ServletService.init(../ServletService.java:31)
        at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(../servlet/JRunSe
rvletLoader.java:203)
        at
allaire.jrun.servlet.JRunSE.initService(../servlet/JRunSE.java:891)
        at
allaire.jrun.servlet.JRunSE.initServices(../servlet/JRunSE.java:858)
        at
allaire.jrun.servlet.JvmContext.initServices(../servlet/JvmContext.java:130)
        at allaire.jrun.servlet.JRunSE.init(../servlet/JRunSE.java:222)
        at
allaire.jrun.servlet.JvmContext.init(../servlet/JvmContext.java:69)
        at allaire.jrun.ServletService.init(../ServletService.java:66)
        at allaire.jrun.ServletService.init(../ServletService.java:31)
        at JRun.main(../../../JRun.java:172)

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to