Weblogic ThreadLocal Memory leaks using AgileAPI in a web application inside tomcat

We are facing issues in all web application inside tomcat that create an Agile Session using AgileAPI.

deploying to tomcat a web application without any other class but just the simple listener attached below:

public class ResourceManagerListener implements ServletContextListener {

private IAgileSession session;

@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println(“opening session”);
HashMap<Integer,String> params = new HashMap<Integer, String>();
AgileSessionFactory instance = AgileSessionFactory.getInstance(“http://myserver:7001/Agile”);
params.put(AgileSessionFactory.USERNAME, “username”);
params.put(AgileSessionFactory.PASSWORD, “password”);
session = instance.createSession(params);
}

@Override
public void contextDestroyed(ServletContextEvent sce) {
session.close();
System.out.println(“session closed”);
}

when the web application is reloaded the session is closed properly but the following local thread leaks are logged by Tomcat

SEVERE: The web application [MyWebApp] created a ThreadLocal with key of type [com.agile.api.common.Security$1] (value [com.agile.api.common.Security$1@1c6d5e6]) and a value of type [java language=”.lang.Boolean”][/java] (value [false]) 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.
SEVERE: The web application [MyWebApp] created a ThreadLocal with key of type [weblogic.kernel.ResettableThreadLocal$1] (value [weblogic.kernel.ResettableThreadLocal$1@1051a02]) and a value of type [weblogic.kernel.ResettableThreadLocal.ThreadStorage] (value [weblogic.kernel.ResettableThreadLocal$ThreadStorage@1ee8b44]) 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.
SEVERE: The web application [MyWebApp] created a ThreadLocal with key of type [weblogic.kernel.ResettableThreadLocal$1] (value [weblogic.kernel.ResettableThreadLocal$1@1051a02]) and a value of type [weblogic.kernel.ResettableThreadLocal.ThreadStorage] (value [weblogic.kernel.ResettableThreadLocal$ThreadStorage@1f92fca]) 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.

The local threads created and related leaks, increases during web application life. After two or three reload of the web application, Tomcat goes in PermGenSpace.

Is there a way using AgileAPI or configuring Weblogic server to close these EJB ThreadLocal before shutting down the web application?

in OTN was submitted the bug 23204821 about it but I would like to know if someone found a workaround for this problem
Thank You

Add Comment
3 Answer(s)

what is the version of weblogic used, looks like bug in weblogic.

meanwhile,  Import wlsauth jar, if any security is causing adhoc closure of thread.
Also, Increase tomcat memory.

Agile Angel Answered on May 12, 2016.
Add Comment

We’re facing the same issue:

org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [/webapp] created a ThreadLocal with key of type [weblogic.kernel.ResettableThreadLocal$1] (value [weblogic.kernel.ResettableThreadLocal$1@501bf5a9]) and a value of type [weblogic.kernel.ResettableThreadLocal.ThreadStorage] (value [weblogic.kernel.ResettableThreadLocal$ThreadStorage@1f9c0d4c]) 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

We’re using many Agile sessions in parallel to get data of different products faster. The question is whether we could fix this issue in our code or we have to wait for an Agile API update.

Agile User Answered on August 30, 2018.
Add Comment

Sorry for the belated question, but did you find solution to your issue?

I do not execute long running task as a web application.

My “solution” to any long running task (anything that doesn’t respond in 2-3 sec max) is to “queue” the task to a SDK based code that processes the job.  I tried Active MQ first, but got shot down by local enterprise architects who wanted me to use IBM WebSphere MQ.   My quick and dirty solution was to use a temp file/folder as the “queue” and have a cronjob that checked if any job(s) were already processing or not,  and if not-processed request found, process it.

For parallel “processing”, I am using different credentials to log into A9. Most of the time, this seems to work, but sometimes, it fails without any valid error log. I think it may be the same issue when two A9 users are trying to update same object at the same time.

Agile Talent Answered on March 29, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.