It's not necessarily bad to use Singletons.  You have to be certain that
they do not hold references to themselves or their class or they cannot be
unloaded.  Google for: permgen log4j.

One thing about log4j -- you should have an ServletContextListener that
shuts down log4j properly:

public class ApplicationLifecycleListener implements ServletContextListener
{
    public void contextDestroyed(ServletContextEvent sce) 
    {
        LogFactory.release(Thread.currentThread().getContextClassLoader());
    }
}

Tim

> -----Original Message-----
> From: Rachel Wilson [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 28, 2007 12:10 PM
> To: 'Tomcat Users List'
> Subject: RE: log4j exception only when stopping and starting a web
> application
> 
> 
> >  This problem is pretty common when restarting web applications.
> Libraries
> >  that use singletons etc. don't get reinitialized correctly when the web
> >  application is reloaded.
> 
> Blimey, that sounds like a serious flaw :S
> 
> Do you know why they don't get reinitialized properly?  Could you give me
> a
> pointer so i can diagnose if this is truly the case in our situation?
> (not
> that i don't believe you but before i tell our administrators that they're
> going to have to do everything differently i'd like to be able to give
> them
> some evidence)
> 
> My administrator assures me that this didn't used to be the case for
> tomcat
> 4.x so what changed i wonder?
> 
> By the way, a couple of things that may be of interest and some further
> relevant questions:
> 
> [1] To cut a long diagnostic story short I found that if you removed the
> leading 3 from the %3x portion of my layout conversionpattern then that
> error is no longer encountered, the webapp restarts and the user is able
> to
> log in.  BUT after my user is successfully returned from LDAP
> authorization
> and (is supposed to be) redirected back to the first page of my
> application... processing stops, all i get is a blank screen and the url
> that ends in j_security_check.  But no errors are logged anywhere that i
> can
> see.
> 
> Q.  Could this be caused by the same reinitialization problem?  We do use
> singletons in our own code.
> 
> [2]  The exact same stop/start problems occur if i deploy a war file under
> /webapps where we specify unpacked="false".  This isn't too surprising,
> however...... my colleague deploys his webapps under a
> $TOMCAT_HOME/myWarfiles directory and has changed the docBase.  (He did
> this
> because of the annoying context.xml deleting/management behaviour and his
> reluctance to include configuration files in a war file to be passed to
> development)  but he can stop/start undeploy/redeploy his (packed)
> warfiles
> with no problem.
> 
> Q.  How does this fit with the reinitialization issue you describe?
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to