Hello, I am one week into programming with Hibernate, and I have been getting a strange exception thrown when I use c3p0 as my connection pool. here is my setup.
hibernate 3.03
mysql 4.1.11
jboss 4.0.1sp1
jdk5
My hibernate.cfg.xml looks like
Code:
<session-factory>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDb?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&mysqlEncoding=utf8</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">rootpass</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">500</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<mapping ... />
<mapping ... />
</session-factory>
So, I am not binding the the SessionFactory object to JNDI because I am providing hibernate.connection.url.
Every once in a while, like about 5, 10, 15 minutes after I call HibernateUtil.currentSession(), execute simple db code, and then closeSession(), I see this exception thrown in the JBoss console:
Code:
2005-05-23 19:38:23,650 INFO [STDOUT] Exception in thread "Timer-7"
2005-05-23 19:38:23,650 INFO [STDOUT] java.lang.NullPointerException
2005-05-23 19:38:23,650 INFO [STDOUT] at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:153)
2005-05-23 19:38:23,650 INFO [STDOUT] at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:464)
2005-05-23 19:38:23,650 INFO [STDOUT] at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:374)
2005-05-23 19:38:23,650 INFO [STDOUT] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
2005-05-23 19:38:23,650 INFO [STDOUT] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
2005-05-23 19:38:23,650 INFO [STDOUT] at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:572)
2005-05-23 19:38:23,666 INFO [STDOUT] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:902)
2005-05-23 19:38:23,666 INFO [STDOUT] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:896)
2005-05-23 19:38:23,666 INFO [STDOUT] at com.mchange.v2.resourcepool.BasicResourcePool.cullExpiredAndUnused(BasicResourcePool.java:940)
2005-05-23 19:38:23,666 INFO [STDOUT] at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:31)
2005-05-23 19:38:23,666 INFO [STDOUT] at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1138)
2005-05-23 19:38:23,666 INFO [STDOUT] at java.util.TimerThread.mainLoop(Timer.java:512)
2005-05-23 19:38:23,666 INFO [STDOUT] at java.util.TimerThread.run(Timer.java:462)
In the first line on the exception clause, I would see "Timer-4", "Timer-8", etc, etc.
Funny thing is, even after these exceptions all my jsp pages and servlets can still perform database I/O's without any problems.
Now, if I disable c3p0 in hibernate.cfg.xml by commenting it and adding in
Code:
<property name="connection.pool_size">50</property>
to enable the hibernate built-in connection pool, I then don't get the exception.
Can anyone please please explain what is going on? It doesn't make me feel right to see these exceptions in a production environment. (although it is not at this point)
Thank you all :)