Problem with scheduler


I am using the scheduler (Scheduled Tasks) to execute a function inside a service bean that I created.

It is started as expected but when I stop tomcat, I get some exceptions for each call (e.g. if it was called 5 times, I get such errors 5 times):

Jan 03, 2019 4:55:20 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNUNG: The web application [pager-core] appears to have started a thread named [ScheduledRunnerThread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)

Jan 03, 2019 4:55:20 PM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SCHWERWIEGEND: The web application [pager-core] created a ThreadLocal with key of type [com.haulmont.cuba.core.sys.ThreadLocalSecurityContextHolder] (value [com.haulmont.cuba.core.sys.ThreadLocalSecurityContextHolder@3aa935ed]) and a value of type [com.haulmont.cuba.core.sys.SecurityContext] (value [SecurityContext{sessionId=99c7b2d3-cf88-d23f-da77-24d135786e92}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

So it seems that the started thread is not ended after the function ended. But the function gets to the end - the last statement is a call which is shown inside the log.

This happens even for almost empty functions. In my tests I just had a call with

log = org.slf4j.LoggerFactory.getLogger(MyServiceBean.class)

Any idea what is going wrong and what I might have to change to remove this problem?

Thank you in advance,

Konrad Neitzel


Thank you for reporting the problem. We’ll fix WARNING messages in the log from scheduled tasks. Issue: Warnings from Scheduled tasks while stop tomcat · Issue #1767 · cuba-platform/cuba · GitHub