-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate,Oracle,c3p0 - connection problem
PostPosted: Sat Mar 04, 2006 8:28 am 
Newbie

Joined: Sat Mar 04, 2006 8:20 am
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: oracle 10g

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

hi all,

i got the following errors :

INFO - Hibernate 3.0rc1

INFO - hibernate.properties not found

INFO - using CGLIB reflection optimizer

INFO - using JDK 1.4 java.sql.Timestamp handling

INFO - configuring from file: hibernate.cfg.xml

INFO - Mapping resource: de/gloegl/road2hibernate/Event.hbm.xml

INFO - Mapping class: de.gloegl.road2hibernate.Event -> EVENTS

INFO - Configured SessionFactory: null

INFO - processing extends queue

INFO - processing collection mappings

INFO - processing association property references

INFO - processing foreign key constraints

INFO - Using dialect: org.hibernate.dialect.Oracle9Dialect

INFO - Default batch fetch size: 1

INFO - Generate SQL with comments: disabled

INFO - Order SQL updates by primary key: disabled

INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory

INFO - Using ASTQueryTranslatorFactory

INFO - Query language substitutions: {}

INFO - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider

INFO - C3P0 using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@ntmrc:1521:dbmrc

INFO - Connection properties: {user=newtc4_07_teste_h}

INFO - autocommit mode: false

INFO - MLog clients using log4j logging.

INFO - Initializing c3p0-0.9.1-pre5a [built 16-February-2006 04:01:24 -0500; debug? true; trace: 10]

INFO - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@c24c0 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1551d7f [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1551d7f, idleConnectionTestPeriod -> 10000, initialPoolSize -> 5, maxIdleTime -> 300, maxPoolSize -> 100, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1d009b4 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1d009b4, jdbcUrl -> jdbc:oracle:thin:@ntmrc:1521:dbmrc, properties -> {user=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], factoryClassLocation -> null, identityToken -> c24c0, numHelperThreads -> 3 ]

WARN - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@64c34e -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!

WARN - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@64c34e -- APPARENT DEADLOCK!!! Complete Status: [num_managed_threads: 3, num_active: 3; activeTasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@15253d5 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0), com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1fddc31 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1), com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1835282 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2); pendingTasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@9df354, com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1d225a7]

WARN - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@15253d5 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).

WARN - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1835282 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).

WARN - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1fddc31 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).

WARN - Could not obtain connection metadata

java.sql.SQLException: Connections could not be acquired from the underlying database!

at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:352)

at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:116)

at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:118)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1497)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1041)

at de.gloegl.road2hibernate.HibernateUtil.<clinit>(HibernateUtil.java:38)

at de.gloegl.road2hibernate.EventManager.store(EventManager.java:55)

at de.gloegl.road2hibernate.EventManager.main(EventManager.java:25)

Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1003)

at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:293)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:348)

... 8 more


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 3:33 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Hi,

1. Post your C3P0 settings like in your c3p0.properties file (I know those can be read from the logs you've provided but it's much easier to be analisez).

2. Probably in your hibernate factory you have two methods getSession, closeSession. post them here too.

3. Depending on your pool implementation you should be able to see the number of total/busy/idle/orphan connections. Log those stats in getSession and closeSesson and see when your pool size is growing.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 4:34 am 
Newbie

Joined: Sat Mar 04, 2006 8:20 am
Posts: 6
TOMBATLECRUISEr wrote:
Hi,

1. Post your C3P0 settings like in your c3p0.properties file (I know those can be read from the logs you've provided but it's much easier to be analisez).

2. Probably in your hibernate factory you have two methods getSession, closeSession. post them here too.

3. Depending on your pool implementation you should be able to see the number of total/busy/idle/orphan connections. Log those stats in getSession and closeSesson and see when your pool size is growing.


1.

<hibernate-configuration>

<session-factory>




<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>





<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@ntmrc:1521:dbmrc</property>
<property name="hibernate.connection.username">newtc4_07_teste_h</property>

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">10000</property>



<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>

<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<mapping resource="de/gloegl/road2hibernate/Event.hbm.xml"/>

</session-factory>

</hibernate-configuration>

2.

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}

!!!!!!!!!


It works in a managed environment and also with org.hsqldb.Server. But I'm just curious if it is a problem of c3p0 or it is my settings problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 5:21 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Hi again,

From your methods I understand that your not using a PooledDataSource or something like that.

My only advice is to set maxStatement to 0 and see if it happents again.
Also try to keep an eye on your session object to see exaclty when it's growing and why (add more debug information when opening, closing a session).

I'm afraid that's all i can say at this moment, I've used C3P0 combined with PooledDataSource, so it's a little different.

If you find any clues post them and maybe someone else or even me could help you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.