[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Failed to stop the worker thread, likely to create a Memory leak.  XML
Forum Index -> Quartz
Author Message
sangram

journeyman

Joined: 06/27/2012 04:01:22
Messages: 28
Offline

I am using a servlet that implements ServletContextListener to start the quartz scheduler instance @ starup. In the contextDestroyed() method, the scheduler instance is stopped.

Code:
    @Override
     public void contextDestroyed(ServletContextEvent sce) {
         try {
             Scheduler scheduler = QuartzSchedulerUtil.getCurrentScheduler();
             scheduler.shutdown(true);
             // Sleep for a bit so that we don't get any errors
             Thread.sleep(1000);
             Driver mySqlDriver = DriverManager.getDriver(hibernateConnectionUrl);
             DriverManager.deregisterDriver(mySqlDriver);
         } catch (SchedulerException ex) {
             Logger.getLogger(QuartzServlet.class.getName()).log(Level.SEVERE, null, ex);
         } catch (InterruptedException ex) {
             Logger.getLogger(QuartzServlet.class.getName()).log(Level.SEVERE, null, ex);
         } catch (SQLException ex) {
             Logger.getLogger(QuartzServlet.class.getName()).log(Level.SEVERE, null, ex);
         }        
         System.out.println("THE QUARTZ APP STOPPED");
     }


But when the application is deployed i get the memory leak warnings specifying that the woker threads are not stopping.

Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/latest-raisin] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/latest-raisin] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/latest-raisin] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/latest-raisin] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak. 


I tried the solution as mentioned in the post - http://forums.terracotta.org/forums/posts/list/15/4341.page
But still getting the Severe memory leak warnings when the appication is undeployed.
alexsnaps

consul

Joined: 06/19/2009 09:06:00
Messages: 481
Offline

I'm slightly confused here, aren't these threads C3P0 ones ?
Isn't your problem related to improper shutdown of the ConnectionPool ?

Alex Snaps (Terracotta engineer)
sangram

journeyman

Joined: 06/27/2012 04:01:22
Messages: 28
Offline

Thanks for the info Sir. Can you please guide how i can get rid of this ConnectionPool shutdown. Am tried the other options like softreset and hardreset after you mentioned. But none, is working for me..

alexsnaps wrote:
I'm slightly confused here, aren't these threads C3P0 ones ?
Isn't your problem related to improper shutdown of the ConnectionPool ? 
alexsnaps

consul

Joined: 06/19/2009 09:06:00
Messages: 481
Offline

I realize I've been unclear... Is Quartz backed by jdbc ? What's with this Hibernate stuff ? Does that use C3P0 ? Is that the same ConnectionPool ? Basically, I wonder if you don't forget to shut something down that results in the ConnectionPool to stay "up"...

Alex Snaps (Terracotta engineer)
sangram

journeyman

Joined: 06/27/2012 04:01:22
Messages: 28
Offline

Yes, its backed by jdbc. We are using quartz scheduler in a struts2 webapp with Hibernate as ORM. Yes its uses C3P0. In Hibernate we use SessionFactory instance to create a new session. In the QuartzServlet's servletContextDestroyed() method i am closing the SessionFactory using sessionFactory.close() which releases all DB relation connections, threads etc., but no luck with that as well.

alexsnaps wrote:
I realize I've been unclear... Is Quartz backed by jdbc ? What's with this Hibernate stuff ? Does that use C3P0 ? Is that the same ConnectionPool ? Basically, I wonder if you don't forget to shut something down that results in the ConnectionPool to stay "up"...  
alexsnaps

consul

Joined: 06/19/2009 09:06:00
Messages: 481
Offline

So is the SessionFactory properly shutdown ? Cause if that uses C3P0 as well, not doing so will result in these same trailing threads... 

You've answered that sorry!
So it'd be nice to know who's C3P0 is leaving threads around...

Alex Snaps (Terracotta engineer)
sangram

journeyman

Joined: 06/27/2012 04:01:22
Messages: 28
Offline

yes its shutting down properly.. i dont find the memory leak with
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] any more

alexsnaps wrote:
So is the SessionFactory properly shutdown ? Cause if that uses C3P0 as well, not doing so will result in these same trailing threads... 

You've answered that sorry!
So it'd be nice to know who's C3P0 is leaving threads around...  
sangram

journeyman

Joined: 06/27/2012 04:01:22
Messages: 28
Offline

Thanks Alex...:)

sangram wrote:
yes its shutting down properly.. i dont find the memory leak with
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] any more

alexsnaps wrote:
So is the SessionFactory properly shutdown ? Cause if that uses C3P0 as well, not doing so will result in these same trailing threads... 

You've answered that sorry!
So it'd be nice to know who's C3P0 is leaving threads around...  
 
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team