avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet AbstractComponentManagerServlet.java ExcaliburComponentManagerServlet.java
Date Thu, 19 Sep 2002 05:41:10 GMT
leif        2002/09/18 22:41:10

  Modified:    component/src/java/org/apache/avalon/excalibur/component/servlet
                        AbstractComponentManagerServlet.java
                        ExcaliburComponentManagerServlet.java
  Log:
  Fix a problem where Tomcat would kick out the following message on shutdown
  because it was invalidating the application class loader before the ECMServet
  could completely dispose of all of its objects:
      WebappClassLoader: Lifecycle error : CL stopped
  
  Revision  Changes    Path
  1.3       +25 -3     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/AbstractComponentManagerServlet.java
  
  Index: AbstractComponentManagerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/AbstractComponentManagerServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractComponentManagerServlet.java	16 Sep 2002 07:42:47 -0000	1.2
  +++ AbstractComponentManagerServlet.java	19 Sep 2002 05:41:10 -0000	1.3
  @@ -103,8 +103,6 @@
       public void init( ServletConfig config )
           throws ServletException
       {
  -        //System.out.println( "AbstractComponentManagerServlet.init( config )" );
  -        
           ServletContext context = config.getServletContext();
   
           // Initialize logging for the servlet.
  @@ -118,6 +116,11 @@
           Logger logger = loggerManager.getLoggerForCategory( "servlet" );
           m_logger = logger.getChildLogger( m_referenceName );
           
  +        if ( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "servlet.init( config )" );
  +        }
  +        
           // Obtain a reference to the ComponentManager
           m_componentManager =
               (ComponentManager)context.getAttribute( ComponentManager.class.getName() );
  @@ -155,11 +158,30 @@
        */
       public void destroy()
       {
  +        if ( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "servlet.destroy()" );
  +        }
  +        
           //System.out.println( "AbstractComponentManagerServlet.destroy()" );
           // Release the ComponentManager by removing its reference.
           m_componentManager = null;
           
           super.destroy();
  +        
  +        // Make sure that the component manager gets collected.
  +        System.gc();
  +        
  +        // Give the system time for the Gc to complete.  This is necessary to make sure
that
  +        //  the ECMServlet has time to dispose all of its managers before the Tomcat server
  +        //  invalidates the current class loader.
  +        try
  +        {
  +            Thread.sleep(250);
  +        }
  +        catch ( InterruptedException e )
  +        {
  +        }
       }
       
       /**
  
  
  
  1.3       +16 -1     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/ExcaliburComponentManagerServlet.java
  
  Index: ExcaliburComponentManagerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/ExcaliburComponentManagerServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExcaliburComponentManagerServlet.java	21 Aug 2002 12:45:11 -0000	1.2
  +++ ExcaliburComponentManagerServlet.java	19 Sep 2002 05:41:10 -0000	1.3
  @@ -109,6 +109,21 @@
    * The ExcaliburComponentManagerServlet makes use of a proxy system to manage
    * reference to the above managers, so it is not necessary to release them
    * when a servlet is done using them.
  + * <p>
  + * It may be necessary to add the following code to the end of the dispose method of any
  + *  servlets referencing any of the above proxies.  This is because on some containers,
  + *  like Tomcat, the classloader is immediately invalidated after the last servlet is
  + *  disposed.  If this happens before the managers have all been disposed, then you may
  + *  see errors in the console like: <code>WebappClassLoader: Lifecycle error : CL
stopped</code>
  + * <pre>
  + *  System.gc();
  + *  try
  + *  {
  + *      Thread.sleep(250);
  + *  }
  + *  catch ( InterruptedException e ) {}
  + * </pre>
  + * Note that servlets which extend the AbstractComponentManagerServlet will behave correctly.
    *
    * @author <a href="mailto:leif@apache.org">Leif Mortenson</a>
    * @version CVS $Revision$ $Date$
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message