-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: c3p0 throws mysterious exceptions
PostPosted: Mon May 23, 2005 10:59 pm 
Newbie

Joined: Wed May 18, 2005 4:11 pm
Posts: 2
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&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;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 :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 1:46 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Since you are using JBoss as AS, simply use its connection pool.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 2:21 am 
Newbie

Joined: Wed May 18, 2005 4:11 pm
Posts: 2
alesj wrote:
Since you are using JBoss as AS, simply use its connection pool.


Hello alesj,

Does that mean I have to create an entry for the datasource in JNDI?
I don't know if I can do this. I have to programmatically instantiate multiple SessionFactory's because the app needs to access more than one database according to user login.

Thanks!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.