1

In continuation with this Websphere hangs due to c3p0 question

Our JSP application itself is a legacy code (written some 5 years back) and we need to maintain it for next 3 years. With the updates to Oracle & WAS the existing code is becoming unstable. Rewriting is not an option due to cost factors

One such problem came when we had to move to Oracle 11. After some research I found out that connection pooling would help. Proper fix is to make changes to the code but cost comes into picture.

After using connection pooing for some time now we found out that the JSP application in WebSphere is hanging more often than normal after introducing C3P0. However introducing c3P0 solved one problem Max cursors reached error in JSP + Hibernate

The Prerequisites on http://www.mchange.com/projects/c3p0/ says C3P0 works well with Java 1.4 and Java 1.5

We are using Java 1.6.x

Has any one had any success in getting c3P0 working with Java 1.6?

Are there any tips/fine tuning that I can do to make c3P0 works with Java 1.6?

My C3P0 settings

 <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
   <property name="hibernate.c3p0.min_size">2</property>
   <property name="hibernate.c3p0.max_size">40</property>
   <property name="hibernate.c3p0.timeout">350</property>
   <property name="hibernate.c3p0.idle_test_period">300</property>
   <property name="hibernate.c3p0.max_statements">0</property>
   <property name="hibernate.c3p0.acquire_increment">1</property>
   <property name="hibernate.c3p0.unreturnedConnectionTimeout">60</property>
   <property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property>
Community
  • 1
  • 1
KK99
  • 1,971
  • 7
  • 31
  • 64

1 Answers1

1

c3p0 works fine in general with java 1.6+.

you might want to upgrade to c3p0 0.9.2.1 or the latest 0.9.5 prerelease if you haven't already (although earlier releases do work in 1.6+).

you'll need to figure out why your app is hanging. in general, during a hang you should dump your Threads and inspect stack traces to see what's going on. if Threads are hanging waiting for Connections from c3p0 (i.e. in the awaitAvailable() method), you probably have a Connection leak and will want to debug it as in the previous hang thread you reference.

Community
  • 1
  • 1
Steve Waldman
  • 13,689
  • 1
  • 35
  • 45
  • Thanks `@steve-waldman` for the answer. I had upgraded to 0.9.5 pre-4 and interestingly the error which came up during startup isn't appearing any more but unfortunately the hang is more than 0.9.2.1. I know that our application is coded very badly but my task to make it run "somehow". So c3p0 is my only option as we can use hte application just by configure c3p0. The web app is so old and complex to change in short time. – KK99 Oct 12 '13 at 14:35
  • the good thing about hangs is that they are debuggable. let your app get into its hang, then have the JVM dump Thread stack traces (e.g. via ctrl-\ or kill -QUIT or ctrl-break on Windows). what are the Threads doing when they hang? if they are in c3p0's awaitAvailable(), then you probably have a Connection leak, which you can debug as per http://stackoverflow.com/questions/17272141/websphere-hangs-due-to-c3p0 if not, well, you'll at least get some idea of what you need to fix! – Steve Waldman Oct 13 '13 at 00:58
  • Thanks. I configured the logs and i see this `2013-10-14 10:32:03,191 WARN [ActiveManagementCoordinator] : A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources.` Any idea what this means? – KK99 Oct 14 '13 at 08:57
  • 1
    Yes. The easiest way to resolve that, if you are not using JMX is to set in c3p0.properties or as a System property `com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator` You could be seeing this due to a bug introduced in the 0.9.2 series and resolved in the latest development snapshot (which will be released soon as c3p0-0.9.5-pre5), or for other reasons. Also, if you are using Tomcat, you might want to set the config properties indicated (under TL; DR) here: http://www.mchange.com/projects/c3p0-0.9.5-pre4/#tomcat-specific – Steve Waldman Oct 15 '13 at 01:07
  • Thanks @steve-waldman we are using WAS 7 & Hibernate. Will check the property you mentioned. – KK99 Oct 15 '13 at 03:30