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 2014/03/27 11:43:45 UTC

[Bug 56321] New: ServletContextListener.contextDestroyed not completely executed when updating war

https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

            Bug ID: 56321
           Summary: ServletContextListener.contextDestroyed not completely
                    executed when updating war
           Product: Tomcat 7
           Version: 7.0.52
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: marco.laponder@kewill.com

When the contextDestroyed accesses a static method on a class which has not
been loaded yet, the rest of the contextDestroyed code is not executed,e.g.,:

package contexttest;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ContextTest implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent arg0) {
        System.out.println("Context Destroyed");
        MyTest.testStatic();
        System.out.println("Context Destroyed Done");

    }

    public void contextInitialized(ServletContextEvent arg0) {
        System.out.println("Context Initialized");
    }

}

package contexttest;

public class MyTest {

    public static void testStatic(){
        System.out.println("My static method call");
    }
}

When I created a war based on this code, and copy this war to the tomcat web
apps directory, it logs 'Context Initialized' as expected.

When I remove the war it logs:
Context Destroyed
My static method call
Context Destroyed Done

as expected. However when I copy the war to web apps, wait till it is
initialized, and then touch the war (to simulate the update of a the war). It
logs for the destroy event only:

'Context Destroyed'

So the static method call and the 'Context Destroyed Done' is missing. 

When I execute the above on tomcat 7.0.42 it behaves as I would expect, so no
difference between removing a war or updating the war.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

Yohei Hina <pi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |piclane@gmail.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

--- Comment #1 from M. Laponder <ma...@kewill.com> ---
Created attachment 31446
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31446&action=edit
test project

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

--- Comment #6 from Konstantin Kolinko <kn...@gmail.com> ---
Created attachment 31688
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31688&action=edit
contexttest.war

WAR file, build from java files in "test project"
Compiled with JDK 1.5 (can be used to test Tomcat 6, if anyone is interested)

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

--- Comment #5 from Yohei Hina <pi...@gmail.com> ---
Is this bug fixed?

I can reproduce this on 7.0.54....

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
OK. Found the problem.

Deleting the WAR triggered a code path the undeployed the app and then deleted
the expanded directory so the new class was available to load during
undeployment. Updating the WAR triggered a code path that deleted the expanded
directory and then undeployed the app. That meant the new class was not
available to load at the point.

I've fixed this my making the process consistent (undeploy then delete).

This has been fixed in 8.0.x for 8.0.6 onwards and 7.0.x for 7.0.54 onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

--- Comment #7 from Konstantin Kolinko <kn...@gmail.com> ---
(In reply to Yohei Hina from comment #5)
> Is this bug fixed?

Yes.
Using the test war attached to this issue, the scenario in the Description
above, current Tomcat 7.0.x and Java 7u55 on Windows, I see that it works
correctly.

[[[
Jun 04, 2014 3:29:30 PM org.apache.catalina.startup.HostConfig undeploy
INFO: Undeploying context [/contexttest]
Context Destroyed
My static method call
Context Destroyed Done
Jun 04, 2014 3:29:30 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive ******\webapps\contexttest.war
Context Initialized
Jun 04, 2014 3:29:30 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive ******\webapps\contexttest.war has
finished in 131 ms
]]]

The commit for this issue is r1582454 (r1582453 for Tomcat 8).

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

Christopher Schultz <ch...@christopherschultz.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #2 from Christopher Schultz <ch...@christopherschultz.net> ---
Are you sure the log hasn't just been buffered? Tomcat doesn't kill threads
like that.

Can you post a thread dump after "Context Destroyed" has been printed?

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

--- Comment #3 from Mark Thomas <ma...@apache.org> ---
The test is using stdout. It is unlikely to be buffered for any noticeable
length of time.

I can reproduce this on 7.0.x. Odd. Trying on 8.0.x...

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56321] ServletContextListener.contextDestroyed not completely executed when updating war

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56321

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michael.bauland@knipp.de

--- Comment #8 from Konstantin Kolinko <kn...@gmail.com> ---
*** Bug 57122 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

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