1

I am using java , GWT, and hibernate with mysql. To avoide too many connection exception I am configuring the c3p0 in my application, but after configuration when I deploy my application to tomcat and run application so after 5 to 10 request application gets crashed and in tomcat logs I am getting following exception repeatedly:

org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/war] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1d2aa39]) and a value of type [com.google.inject.servlet.ServletDefinition$2] (value [com.google.inject.servlet.ServletDefinition$2@ef3675]) 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.

My c3p0 configuration is as follows:

<property name="connection.provider_class"> org.hibernate.connection.C3P0ConnectionProvider</property>
   <property name="hibernate.connection.autoReconnect">true</property>
   <property name="hibernate.c3p0.acquire_increment">3</property>
   <property name="hibernate.c3p0.idle_test_period">5</property>
   <property name="hibernate.c3p0.max_size">50</property>
   <property name="hibernate.c3p0.max_statements">0</property>
   <property name="hibernate.c3p0.min_size">0</property>
   <property name="hibernate.c3p0.timeout">5</property>
   <property name="hibernate.c3p0.idleConnectionTestPeriod">5</property>

help me if anyone knows the solution... thanks in advance..

milind_db
  • 1,274
  • 5
  • 34
  • 56
  • Please post, what does it mean "application gets crashed"? As Marko has marked, that SEVERE warning by Tomcat is not a cause – Nikem Jul 24 '12 at 03:41
  • application crashed in the sense after this exception, any database request is not getting invoked...it repeatedly trows memory leak exception. – milind_db Jul 24 '12 at 06:55
  • Sorry guy, you are not specific. First of all in your question there is no exception. Just SEVERE log message. Secondly, "database request is not getting invoked" is not an exception in java sense of the world. Thirdly, there is no such thing in java as "memory leak exception". If you ask for help, please provide exact information. – Nikem Jul 25 '12 at 17:22

3 Answers3

2

This is not the cause of your crash, but its effect—your app has crashed for a yet unknown reason and left a mess behind it. The error pertains to that mess.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
  • Marko: When these exceptions are coming after that my application is crashing. and it is not for this app I also tried this into another app also...there also I was getting same exception in tomcat. – milind_db Jul 23 '12 at 10:09
  • Tomcat is just notifying you that there's a potential memory leak due to abandoned `ThreadLocal`s. It is taking proactive measures to fight that leak. Those measures are not causing your crash, but the other way around. – Marko Topolnik Jul 23 '12 at 10:12
2

This is a class-loader related memory leak that occurs when you redeploy your application.

For more information on this type of memory leak, see this question.

The problem in your case is a bug in the Guava dependency of Google Guice.

Community
  • 1
  • 1
Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102
0

This is not the cause of your exception ,but the outcome of the exception. The most probable reason of your app crash is memory leaks in your code. Before doing anything make sure your connection are properly closed in finally block...

Mahesh More
  • 919
  • 2
  • 8
  • 20