You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Ronel Sumibcay <su...@INNOTIV.COM> on 2002/04/01 21:37:04 UTC

RE: Problems with 1.1b1

I take back where the fix should take place. Its really a J2EE issue so the
fix should really take place in the servlet container before it calls the
init() method of a preloaded servlet. 

Folks with commit priveledges...what do you guys think? Will it hurt to have
this change in the ActionServet's init() method? Should struts attempt to
cater to partially compliant J2EE servlet containers? Or should I take this
problem to the tomcat and jrun lists?

The answer to these questions will help me decide if i should make a
struts-myfix.jar or wait for a stable strtus 1.1 with the fix, or wait for
jrun with a bug fix.

Thanks.

-ronel



-----Original Message-----
From: Ronel Sumibcay [mailto:sumibcay@INNOTIV.COM]
Sent: Friday, March 29, 2002 3:59 PM
To: 'Struts Developers List'
Subject: RE: Problems with 1.1b1



The problem may be that the servlet engine may not be calling 

Thread.setContextClassLoader(ClassLoader) when initializing a servlet from
preload.

This seems to be the case for JRun3.1. It may be the same for Tomcat 3.3a.
I've made the fix to my ActionServlet, but I think it really needs to be
done in LogFactory.findClassLoader(). The fix for ActionServlet involves
moving the LogFactory.getLog() into the init() method of ActionServlet

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

        initInternal();
        initOther();
        initServlet();

	...
}

The LogFactory.findClassLoader() checks for null to the call to 
Thread.currentThread().getContextClassLoader(), but according to the docs it
either the primordial classloader or the classloader set when the thread was
created. It seems like it was never set, so the primordial classloader is
being returned, thus the ClassNotFoundExceptions.

Hope this helps

-ronel


-----Original Message-----
From: Martin Cooper [mailto:martin.cooper@tumbleweed.com]
Sent: Friday, March 22, 2002 10:15 PM
To: Struts Developers List
Subject: Re: Problems with 1.1b1


Unfortunately, you're not the only one seeing these problems. I really
thought I'd tested the struts-example app with four different containers
(Tomcat 3.3a, Tomcat 4.0.3, Resin 1.2.10, Resin 2.0.5) before I released the
beta, but it seems I must not have tested under Tomcat 3.3a. ;-( The other
three work just fine.

Here's what I know so far:

1) The problem is related to class loaders, and possibly to the
LogFactory.findClassLoader() method. The fact that LogFactory.getLog() is
called at (ActionServlet) class initialisation time may also be significant.

2) It is related to the <load-on-startup> element. If the web app is not
loaded on startup, this error does not occur. (Others do, of course, but we
get past this problem.)

3) The problem can be worked around by copying commons-logging.jar to:

    %TOMCAT_HOME%\lib\common

Unfortunately, I'm by no means a class loader expert, so I'm not sure where
to go from here. Hopefully someone who has more class loader knowledge than
I do can chip in now...

--
Martin Cooper


----- Original Message -----
From: "Cedric Dumoulin" <ce...@lifl.fr>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, March 22, 2002 9:50 AM
Subject: Re: Problems with 1.1b1


>
>   After playing with different configurations, here are my conclusions :
>
>    * 1.1b1 struts-example work fine with tomcat4.0.3 and jdk1.4
>    * 1.1b1 struts-example doesn't work with tomcat3.3a and jdk1.4 (can't
find
>      LogFactory.java)
>    * 1.1b1 struts-example doesn't work with tomcat3.3a and jdk1.3 (can't
find
>      LogFactory.java)
>
>   Am I the only one having these problems ? Does someone else have tried
and got 1.1b1
> running with tomcat3.3.
>   Of course, the commons logging package is in WEB-INF/lib/..
>
>      Cedric
>
> Cedric Dumoulin wrote:
>
> >   I have downloaded and try the 1.1b1 binaries, and can't get it running
> > !
> >   I use tomcat 3.2.3 and jdk1.3.
> >
> >   Does someone have successfully tested the binaries distribution ?
> >
> >   When trying the struts-examples, I've got :
> >
> > java.lang.ExceptionInInitializerError:
> > 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.util.MessageResourcesFactory.(MessageResourcesFactory.java
:135)
> >
> >         at
> >
org.apache.struts.util.MessageResources.getMessageResources(MessageResources
.java:557)
> >
> >         at org.apache.struts.taglib.html.HtmlTag.(HtmlTag.java:94)
> >
> >   Cedric
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problems with 1.1b1

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 1 Apr 2002, Craig R. McClanahan wrote:

>
> * Such support was *not* required in J2EE 1.3 (and therefore Servlet 2.2)
>   environments, but it is widely supported.
>

Err, that should have said J2EE 1.2 rather than 1.3.

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problems with 1.1b1

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 1 Apr 2002, Ronel Sumibcay wrote:

> Date: Mon, 1 Apr 2002 11:37:04 -0800
> From: Ronel Sumibcay <su...@INNOTIV.COM>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: 'Struts Developers List' <st...@jakarta.apache.org>
> Subject: RE: Problems with 1.1b1
>
> I take back where the fix should take place. Its really a J2EE issue so the
> fix should really take place in the servlet container before it calls the
> init() method of a preloaded servlet.
>
> Folks with commit priveledges...what do you guys think? Will it hurt to have
> this change in the ActionServet's init() method? Should struts attempt to
> cater to partially compliant J2EE servlet containers? Or should I take this
> problem to the tomcat and jrun lists?
>
> The answer to these questions will help me decide if i should make a
> struts-myfix.jar or wait for a stable strtus 1.1 with the fix, or wait for
> jrun with a bug fix.
>
> Thanks.
>

There are a couple of dimensions to this issue:

* J2EE 1.3 (and therefore Servlet 2.3) require that the thread context
  class loader be initialized appropriately for all web applications.
  For example, Tomcat 4 does this.

* Such support was *not* required in J2EE 1.3 (and therefore Servlet 2.2)
  environments, but it is widely supported.

* Tomcat 3.x purports to support this feature, but IIRC you have to
  explicitly configure it in server.xml by including a particular
  interceptor or something.  Have you got this set up correctly?

* If you have indeed configured this as required, I would suggest it is
  probably a Tomcat 3.3 bug -- it should set up the same context class
  loader for actually loading the servlet class (which fires off the
  getLog() initializers) as it does when calling the service() method.

* The issue is not Struts-specific ... it would affect *any* web app
  that uses the recommended logger discovery mechanism, fired when the
  servlet is initially loaded.

Given that, has anyone reported this as a Tomcat 3.3 bug?

> -ronel
>

Craig


>
>
> -----Original Message-----
> From: Ronel Sumibcay [mailto:sumibcay@INNOTIV.COM]
> Sent: Friday, March 29, 2002 3:59 PM
> To: 'Struts Developers List'
> Subject: RE: Problems with 1.1b1
>
>
>
> The problem may be that the servlet engine may not be calling
>
> Thread.setContextClassLoader(ClassLoader) when initializing a servlet from
> preload.
>
> This seems to be the case for JRun3.1. It may be the same for Tomcat 3.3a.
> I've made the fix to my ActionServlet, but I think it really needs to be
> done in LogFactory.findClassLoader(). The fix for ActionServlet involves
> moving the LogFactory.getLog() into the init() method of ActionServlet
>
> public void init()
> {
>
> Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader(
> ));
>       log = LogFactory.getLog(this.getClass());
>
>         initInternal();
>         initOther();
>         initServlet();
>
> 	...
> }
>
> The LogFactory.findClassLoader() checks for null to the call to
> Thread.currentThread().getContextClassLoader(), but according to the docs it
> either the primordial classloader or the classloader set when the thread was
> created. It seems like it was never set, so the primordial classloader is
> being returned, thus the ClassNotFoundExceptions.
>
> Hope this helps
>
> -ronel
>
>
> -----Original Message-----
> From: Martin Cooper [mailto:martin.cooper@tumbleweed.com]
> Sent: Friday, March 22, 2002 10:15 PM
> To: Struts Developers List
> Subject: Re: Problems with 1.1b1
>
>
> Unfortunately, you're not the only one seeing these problems. I really
> thought I'd tested the struts-example app with four different containers
> (Tomcat 3.3a, Tomcat 4.0.3, Resin 1.2.10, Resin 2.0.5) before I released the
> beta, but it seems I must not have tested under Tomcat 3.3a. ;-( The other
> three work just fine.
>
> Here's what I know so far:
>
> 1) The problem is related to class loaders, and possibly to the
> LogFactory.findClassLoader() method. The fact that LogFactory.getLog() is
> called at (ActionServlet) class initialisation time may also be significant.
>
> 2) It is related to the <load-on-startup> element. If the web app is not
> loaded on startup, this error does not occur. (Others do, of course, but we
> get past this problem.)
>
> 3) The problem can be worked around by copying commons-logging.jar to:
>
>     %TOMCAT_HOME%\lib\common
>
> Unfortunately, I'm by no means a class loader expert, so I'm not sure where
> to go from here. Hopefully someone who has more class loader knowledge than
> I do can chip in now...
>
> --
> Martin Cooper
>
>
> ----- Original Message -----
> From: "Cedric Dumoulin" <ce...@lifl.fr>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Friday, March 22, 2002 9:50 AM
> Subject: Re: Problems with 1.1b1
>
>
> >
> >   After playing with different configurations, here are my conclusions :
> >
> >    * 1.1b1 struts-example work fine with tomcat4.0.3 and jdk1.4
> >    * 1.1b1 struts-example doesn't work with tomcat3.3a and jdk1.4 (can't
> find
> >      LogFactory.java)
> >    * 1.1b1 struts-example doesn't work with tomcat3.3a and jdk1.3 (can't
> find
> >      LogFactory.java)
> >
> >   Am I the only one having these problems ? Does someone else have tried
> and got 1.1b1
> > running with tomcat3.3.
> >   Of course, the commons logging package is in WEB-INF/lib/..
> >
> >      Cedric
> >
> > Cedric Dumoulin wrote:
> >
> > >   I have downloaded and try the 1.1b1 binaries, and can't get it running
> > > !
> > >   I use tomcat 3.2.3 and jdk1.3.
> > >
> > >   Does someone have successfully tested the binaries distribution ?
> > >
> > >   When trying the struts-examples, I've got :
> > >
> > > java.lang.ExceptionInInitializerError:
> > > 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.util.MessageResourcesFactory.(MessageResourcesFactory.java
> :135)
> > >
> > >         at
> > >
> org.apache.struts.util.MessageResources.getMessageResources(MessageResources
> .java:557)
> > >
> > >         at org.apache.struts.taglib.html.HtmlTag.(HtmlTag.java:94)
> > >
> > >   Cedric
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>