2011-05-19

APPARENT DEADLOCK with c3p0

When using Hibernate, JBoss 6, MySQL/HSQLDB, c3p0 for connection pooling, I got the following error (not a warning, as the log level seems to suggest) while running transactional JPA code.

WARN  [com.mchange.v2.async.ThreadPoolAsynchronousRunner]
(Timer-1) com.mchange.v2.async.ThreadPoolAsynchronousRunner
$DeadlockDetector@26d6221b -- APPARENT DEADLOCK!!!
(line breaks added for readability)

I'm sure there might be more than one reason for this. However, in my case what caused it was duplicate c3p0 declarations - I had them in two places:
  • persistence.xml file
  • dogs-ds.xml file (JBoss data source file)

The solution was to remove these lines from persistence.xml (which makes sense since the data source declaration is JBoss' job):

<property name="hibernate.c3p0.max_size" value="100" />
...

No more deadlock!

1 comment: