You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2005/03/24 14:37:37 UTC

DO NOT REPLY [Bug 34164] New: - context attributes not available when servlet's destroy() is called

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34164>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34164

           Summary: context attributes not available when servlet's
                    destroy() is called
           Product: Tomcat 5
           Version: 5.5.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: mguillemot@yahoo.fr


In Tomcat 5.5.7, the context attributes seem to have been removed before the
method destroy() of the loaded servlets is called. This is not the case with
Tomcat 5.0.28 and I guess that it is wrong because Struts for instance relies on
it to destroy its modules (in
org.apache.struts.action.ActionServlet#destroyModules).

In the case of struts, this causes the plugins not to be notified that they are
destroyed what is against their expected behavior.

A simple servlet illustrates the problem:

public class TestServlet extends HttpServlet
{
  public void init() throws ServletException
  {
    log("In init TestServlet");
    getServletContext().setAttribute("test", "test");
    log("Attribute test: " + getServletContext().getAttribute("test"));
  }

  public void destroy()
  {
    log("In destroy TestServlet");
    log("Attribute test: " + getServletContext().getAttribute("test"));
    super.destroy();
  }
}

Configured with:
  <servlet>
    <servlet-name>test</servlet-name>
    <description>Custom test</description>
    <servlet-class>de.internetzky.test.TestServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>
	

  <servlet-mapping>
    <servlet-name>test</servlet-name>
    <url-pattern>/foo/*</url-pattern>
  </servlet-mapping>

Gives following output in Tomcat 5.5.7:

INFO main org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/test]
- test: In init TestServlet
 INFO main org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/test]
- test: Attribute test: test

INFO http-8080-Processor24
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/test] - test: In
destroy TestServlet
 INFO http-8080-Processor24
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/test] - test:
Attribute test: null

but in Tomcat 5.0.28:
StandardContext[/test]test: In init TestServlet
StandardContext[/test]test: Attribute test: test

StandardContext[/test]test: In destroy TestServlet
StandardContext[/test]test: Attribute test: test

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org