Tomcat crashes when using quartz and frames

I use struts and a quartz structure for job scheduling. It works great.

But when I stop Tomcat (6.0.26), it gives an error on the console, for example

“The web application seems to have started a thread with the name [.....], but could not stop it. This will probably lead to a memory leak.

Does anyone know how to handle this gracefully ...

My struts config.xml currently looks like this: <plug-in className="com.example.scheduler.SchedulerPlugin"> <set-property property="startOnLoad" value="true"/> <set-property property="startupDelay" value="0"/> </plug-in>

+3
source share
3 answers

The best way to know for sure is to send the SIGQUIT program (kill -3) and analyze the output to see which thread is still running.

, ( ) . jobExecutionContext.getScheduler().isShutdown() , InterruptableJob .

+5

scheduler.shutdown(true), Quartz - .

, tomcat , , cpu , tomcat , .

: http://forums.terracotta.org/forums/posts/list/3479.page

+4

jhouse. : - (.

, ServletContextListener web.xml:

<listener>
    <listener-class>org.whatever.MyListener</listener-class>
</listener>

Then in the implementation, in the context of the contextDestroyed () method, sleep for 10 seconds (1 second was not enough for my application). It should look something like this:

public class MyListener implements ServletContextListener {


    public void contextInitialized(ServletContextEvent arg0) {}

    /**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
        try {
            // This can't use logging because it (hopefully) been shut down by now.
            System.out.println("Sleep for a bit so that we don't get any errors about Quartz threads not being shut down yet. ");
            // For more info, see here: http://stackoverflow.com/questions/2730354/spring-scheduler-shutdown-error
            Thread.sleep(10 * 1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

I did not need to call the scheduler shutdown methods (it was clear that they were already called somewhere, maybe because I use Spring). All I had to do was add the wait, and then they all left (except for the FileWatchdog Log4j stream and some other MySQL stream, but these are different issues).

+3
source

Source: https://habr.com/ru/post/1796188/


All Articles