Spring JPA unknown error but application works as expected - java

I'm using Spring 4.0, tomcat 8, spring-data-jpa 1.7.0.RELEASE, hibernate 4.1, mysql 5.6.21 Homebrew. I'm new in java, just moved form C++ background. I assume there must be some resource leaking. I have to close or free something before I exist the app. But no idea what to do. Please advise me!
Every time I restart I got following error:-
Nov 20, 2014 2:01:01 PM org.apache.catalina.loader.WebappClassLoaderBase
clearReferencesThreads
WARNING: The web application [MyJap] appears to have started a thread named [MySQL
Statement Cancellation Timer] but has failed to stop it. This is very likely to create a
memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:502)
java.util.TimerThread.mainLoop(Timer.java:526)
java.util.TimerThread.run(Timer.java:505)
Nov 20, 2014 2:01:01 PM org.apache.coyote.AbstractProtocol start

Related

How to stop threads created by org.asynchttpclient to prevent memory leak?

I am using org.asynchttpclient to post async request.
While shutting down tomcat, I am getting below logs:
SEVERE: The web application [/test] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Jul 04, 2017 10:53:00 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/test] appears to have started a thread named [AsyncHttpClient-2-1] but has failed to stop it. This is very likely to create a memory leak.
Jul 04, 2017 10:53:00 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/test] appears to have started a thread named [AsyncHttpClient-2-2] but has failed to stop it. This is very likely to create a memory leak.
Jul 04, 2017 10:53:00 AM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#71513074]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap#4aecc2e8]) 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.
How to close these threads to prevent memory leak.
This is really more of a warning and in most times can be ignored. You will see this error when the context is reloaded or shut down. If you are shutting down the server then the JVM will be shutdown also and the os will clean up any memory.
If you want to try and call close on the AsyncHttpClient which implements Closable it may stop this issue. You will probably have to put a wait in there to let it fully close the connection factory. You can look at the tomcat Lifecycle to add a shutdown handler to handle closing the client.

Quartz2.x: GRAVE: The web application [/servlet] appears to have started a thread named [Thread-4] but has failed to stop it

I am getting this message when I run my web application with Quartz 2.x . It runs fine but I get this error during stating server
INFO: Server startup in 1792 ms
20 mai 2014 18:18:59 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
GRAVE: The web application [/servlet] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak.
20 mai 2014 18:18:59 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
GRAVE: The web application [/servlet] appears to have started a thread named [CronTriggers_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
20 mai 2014 18:18:59 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
GRAVE: The web application [/servlet] appears to have started a thread named [CronTriggers_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
Any help appreciated.
This may be caused by not shutting down the Quartz scheduler upon Tomcat shutdown or web-application redeploy (most likely your case).
You will need to implement a ServletContextListener and in its contextDestroyed method you will need to do this:
scheduler.shutdown( true ); // true = wait for jobs to complete
// you may want to give Quartz some extra time to shutdown
//Thread.sleep(1000);
You may also want to configure the Quartz thread-pool to mark its threads as "daemon threads" (org.quartz.threadPool.makeThreadsDaemons=true) as they will not block the JVM from stopping. Otherwise, the JVM will wait for all these worker threads to finish.

Tomcat memory leak - Stopping Guava Finalizer thread

I have a Spring web application running on Tomcat.
When trying to shutdown Tomcat with the shutdown.sh script, the java process doesn't end because it has a Thread that's still running. The catalina.log contains
Jul 22, 2013 2:07:50 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myapp] appears to have started a thread named [com.google.common.base.internal.Finalizer] but has failed to stop it. This is very likely to create a memory leak.
Apparently BoneCP has some Guava integration that causes this thread to block. Is there a clean or intended way to kill this thread?
There's an open issue on Guava for this problem - the issue itself is pretty old but if you check the latest comments you'll see some suggestions from other BoneCP users to resolve this issue
Also check this other issue and this patch

Tomcat throws java.lang.UnsupportedOperationException when my Application is undeployed

When I undeploy my application from Tomcat, I see below errors in Tomcat logs. What could be the issue? How I should fix this issue.
----------------------------Tomcat log ---------------------------
SEVERE: The web application [/dfsmonitor] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#6ca32e]) and a value of type [com.sun.xml.stream.XMLReaderImpl] (value [com.sun.xml.stream.XMLReaderImpl#e01430]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Jul 1, 2012 10:18:20 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: Unable to determine string representation of value of type [com.sun.xml.stream.writers.XMLStreamWriterImpl]
java.lang.UnsupportedOperationException
at com.sun.xml.stream.writers.XMLStreamWriterImpl.entrySet(XMLStreamWriterImpl.java:2134)
at java.util.AbstractMap.toString(AbstractMap.java:478)
at org.apache.catalina.loader.WebappClassLoader.clearThreadLocalMap(WebappClassLoader.java:2433)
at org.apache.catalina.loader.WebappClassLoader.clearReferencesThreadLocals(WebappClassLoader.java:2349)
at org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1921)
at org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.java:1833)
at org.apache.catalina.loader.WebappLoader.stop(WebappLoader.java:740)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4913)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:932)
at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1357)
at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1328)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:326)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1094)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1106)
at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:468)
at org.apache.catalina.core.StandardService.stop(StandardService.java:604)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:788)
at org.apache.catalina.startup.Catalina.stop(Catalina.java:662)
at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 1, 2012 10:18:20 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/dfsmonitor] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#1bf8785]) and a value of type [com.sun.xml.stream.writers.XMLStreamWriterImpl] (value [Unknown]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Jul 1, 2012 10:18:20 PM org.apache.coyote.http11.Http11AprProtocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Please let me know what could be the issue.
You could avoid placing XMLStreamWriterImpl instances into thread locals, that way upon shutdown Tomcat wouldn't have any issues removing them.
But other than actually implementing the destroy method on a Servlet, or registering shutdown hooks in an environment such as Spring and tracking all the values you've ever set into threadlocals just so you can remove them upon shutdown, I don't think you really need to worry about this. Though it is odd that you, or code you're using, is storing this value into a threadlocal - typically stream writers are created and destroyed quickly and don't persist very long.

Tomcat Memory Leak Using Struts2 xwork

SEVERE: The web application [/ppAdmin] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#126212dd]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#64c47498]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:00 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/ppAdmin] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#1dc2dad7]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#63ad6884]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:00 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/ppAdmin] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#1dc2dad7]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#da8e53c]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/Nemo] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/Nemo] registered the JDBC driver [net.sourceforge.jtds.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/Nemo] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/Nemo] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#28318d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#4ecd200f]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/Nemo] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#7cf3e133]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#6f461b5b]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/Nemo] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#28318d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#63ae2c6f]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/Nemo] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#28318d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#3fe75e89]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/Nemo] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10#28318d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;#6eef9525]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 22, 2012 12:43:01 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
WHY THE MEMORY LEAK WARNINGS ARE THERE???TOMCAT 6.0.35 ALLOWS GC TOOL.STILL IT GIVES SUCH WARNINGS.I AM BOTHERED ABOUT THESE WARNINGS.PLEASE HELP ME HOW TO MANAGE WITH THESE?
ANY HELP WILL BE HIGHLY APPRECIATED..................THANKS IN ADVANCE.
I had the same problem with Tomcat 6 and Struts2 2.1.8 webapp (maven 3.0.3 + eclipse keepler + JDK 1.6.0_22). I'm new in struts2+tomcat developing and I'm not used to solve this kind of problems.
After having made some changes on my code (and don't use svn nor git...), and after start using a mvn tomcat:redeploy task (witch confused me) I had this same behavior, and don't know what were causing to fail the deployment (the project keeps compiling ok).
The error seems so confusing and zero descriptive to me, and I've read many related posts. I've tryed to update the struts2 version, cause I've read that this kind of problems seems solved in struts2 2.3.3 (was using 2.1.8).
https://issues.apache.org/jira/browse/WW-3768
I dont't know why I was just reading catalina log:
SEVERE: Error filterStart
12/02/2014 10:46:23 org.apache.catalina.core.StandardContext start
SEVERE: Context [/validador] startup failed due to previous errors
The answer was very close, in localhost-date.log!
That point me to a bad declared action in struts.xml, so simple to solve and so descriptive, but so dificult to figure out just reading catalina log.
SEVERE: Exception starting filter struts2
Unable to load configuration. - action - file:/C:/apps/apache-tomcat- 6.0.39/webapps/validador/WEB-INF/classes/struts.xml:74:83
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
...
...
Caused by: Action class [aoc.action.signature.CompletePDFUpload] not found - action - file:/C:/apps/apache-tomcat-6.0.39/webapps/validador/WEB-INF/classes/struts.xml:74:83
I hope someone else missed to check the correct log and solve as easy as me their problem.

Categories

Resources