Hi,
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)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
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 log.info call which is shown inside the log.
This happens even for almost empty functions. In my tests I just had a log.info 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