You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Tomasz Nurkiewicz (JIRA)" <ji...@apache.org> on 2012/11/24 22:52:58 UTC

[jira] [Created] (MTOMCAT-186) Closing executable JAR does not call ServletContextListener.contextDestroyed()

Tomasz Nurkiewicz created MTOMCAT-186:
-----------------------------------------

             Summary: Closing executable JAR does not call ServletContextListener.contextDestroyed()
                 Key: MTOMCAT-186
                 URL: https://issues.apache.org/jira/browse/MTOMCAT-186
             Project: Apache Tomcat Maven Plugin
          Issue Type: Bug
          Components: tomcat7
    Affects Versions: 2.0
         Environment: Java 7, maven 3.0.3
            Reporter: Tomasz Nurkiewicz
            Assignee: Olivier Lamy (*$^¨%`£)
            Priority: Minor


Executable JAR created by {{tomcat7-maven-plugin:exec-war-only}} does not call {{ServletContextListener.contextDestroyed()}} callback method when Java process is killed or when Ctrl + C is pressed. There is no way (?) to cleanly shutdown web application.

The same application (attached) deployed on standalone Tomcat works just fine. Hitting Ctrl + C correctly undeploys and shuts down application.

Build attached application and run {{java -jar target/standalone.jar}}. Ctrl + C kills the process immediately. On the other hand {standalone.war}} deployed to normal Tomcat under {{/webapps}} shuts down correctly and we can see log statement from {{contextDestroyed()}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (MTOMCAT-186) Closing executable JAR does not call ServletContextListener.contextDestroyed()

Posted by "Konstantin Kolinko (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MTOMCAT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13508371#comment-13508371 ] 

Konstantin Kolinko commented on MTOMCAT-186:
--------------------------------------------

The shutdown hook used by o.a.c.startup.Catalina is Catalina$CatalinaShutdownHook.  Maybe it could be generalized, or a similar class should be added to be used with o.a.c.startup.Tomcat.


If someone is going to create a copy of the shutdown hook class, maybe I should explain one implementation detail:

Note that the logging subsystem installs its own shutdown hook as well.  When JVM shuts down, it starts all hooks in parallel without any order, so there is a risk that some log messages will be lost as the logging system will be shut down too early.

This issue is already solved in Catalina$CatalinaShutdownHook, but the solution works only when Tomcat's JULI ClassLoaderLogManager is used.  It does not work with plain java.util.logging.LogManager which I think is used when running a JAR file.

I see that Tomcat7Runner.installLogger() may install "org.slf4j.bridge.SLF4JBridgeHandler". I do not know how to deal with that one either.


The solution works like the following:

First, it should be noted that the following 3 hooks are installed:
a) java.util.logging.LogManager$Cleaner
b) org.apache.juli.ClassLoaderLogManager$Cleaner
c) org.apache.catalina.startup.Catalina$CatalinaShutdownHook

To ensure that the logging subsystem is shutdown by CatalinaShutdownHook only, the following is used:

1. "a)" is dealt with in ClassLoaderLogManager.reset() where it ignores a call from LogManager$Cleaner
2. "b)" is dealt with in Catalina.start() where it calls ClassLoaderLogManager.setUseShutdownHook(false) after installing its own shutdown hook
3.  Catalina$CatalinaShutdownHook.run() calls ClassLoaderLogManager.shutdown()

http://svn.apache.org/viewvc?view=revision&revision=910974
http://svn.apache.org/viewvc?view=revision&revision=918885
                
> Closing executable JAR does not call ServletContextListener.contextDestroyed()
> ------------------------------------------------------------------------------
>
>                 Key: MTOMCAT-186
>                 URL: https://issues.apache.org/jira/browse/MTOMCAT-186
>             Project: Apache Tomcat Maven Plugin
>          Issue Type: Bug
>          Components: tomcat7
>    Affects Versions: 2.0
>         Environment: Java 7, maven 3.0.3
>            Reporter: Tomasz Nurkiewicz
>            Assignee: Olivier Lamy (*$^¨%`£)
>            Priority: Minor
>             Fix For: 2.1
>
>         Attachments: listener.zip
>
>
> Executable JAR created by {{tomcat7-maven-plugin:exec-war-only}} does not call {{ServletContextListener.contextDestroyed()}} callback method when Java process is killed or when Ctrl + C is pressed. There is no way (?) to cleanly shutdown web application.
> The same application (attached) deployed on standalone Tomcat works just fine. Hitting Ctrl + C correctly undeploys and shuts down application.
> Build attached application and run {{java -jar target/standalone.jar}}. Ctrl + C kills the process immediately. On the other hand {standalone.war}} deployed to normal Tomcat under {{/webapps}} shuts down correctly and we can see log statement from {{contextDestroyed()}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (MTOMCAT-186) Closing executable JAR does not call ServletContextListener.contextDestroyed()

Posted by "Tomasz Nurkiewicz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MTOMCAT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tomasz Nurkiewicz updated MTOMCAT-186:
--------------------------------------

    Attachment: listener.zip
    
> Closing executable JAR does not call ServletContextListener.contextDestroyed()
> ------------------------------------------------------------------------------
>
>                 Key: MTOMCAT-186
>                 URL: https://issues.apache.org/jira/browse/MTOMCAT-186
>             Project: Apache Tomcat Maven Plugin
>          Issue Type: Bug
>          Components: tomcat7
>    Affects Versions: 2.0
>         Environment: Java 7, maven 3.0.3
>            Reporter: Tomasz Nurkiewicz
>            Assignee: Olivier Lamy (*$^¨%`£)
>            Priority: Minor
>         Attachments: listener.zip
>
>
> Executable JAR created by {{tomcat7-maven-plugin:exec-war-only}} does not call {{ServletContextListener.contextDestroyed()}} callback method when Java process is killed or when Ctrl + C is pressed. There is no way (?) to cleanly shutdown web application.
> The same application (attached) deployed on standalone Tomcat works just fine. Hitting Ctrl + C correctly undeploys and shuts down application.
> Build attached application and run {{java -jar target/standalone.jar}}. Ctrl + C kills the process immediately. On the other hand {standalone.war}} deployed to normal Tomcat under {{/webapps}} shuts down correctly and we can see log statement from {{contextDestroyed()}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (MTOMCAT-186) Closing executable JAR does not call ServletContextListener.contextDestroyed()

Posted by "Olivier Lamy (*$^¨%`£ JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MTOMCAT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Olivier Lamy (*$^¨%`£) updated MTOMCAT-186:
-------------------------------------------

    Fix Version/s: 2.1
    
> Closing executable JAR does not call ServletContextListener.contextDestroyed()
> ------------------------------------------------------------------------------
>
>                 Key: MTOMCAT-186
>                 URL: https://issues.apache.org/jira/browse/MTOMCAT-186
>             Project: Apache Tomcat Maven Plugin
>          Issue Type: Bug
>          Components: tomcat7
>    Affects Versions: 2.0
>         Environment: Java 7, maven 3.0.3
>            Reporter: Tomasz Nurkiewicz
>            Assignee: Olivier Lamy (*$^¨%`£)
>            Priority: Minor
>             Fix For: 2.1
>
>         Attachments: listener.zip
>
>
> Executable JAR created by {{tomcat7-maven-plugin:exec-war-only}} does not call {{ServletContextListener.contextDestroyed()}} callback method when Java process is killed or when Ctrl + C is pressed. There is no way (?) to cleanly shutdown web application.
> The same application (attached) deployed on standalone Tomcat works just fine. Hitting Ctrl + C correctly undeploys and shuts down application.
> Build attached application and run {{java -jar target/standalone.jar}}. Ctrl + C kills the process immediately. On the other hand {standalone.war}} deployed to normal Tomcat under {{/webapps}} shuts down correctly and we can see log statement from {{contextDestroyed()}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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