-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate c3p0 data source jndi-Acquisition Attempt failed
PostPosted: Tue Mar 03, 2015 3:02 pm 
Newbie

Joined: Thu May 01, 2014 4:09 pm
Posts: 3
Hi
I am integrating c3p0 with hibernate. Prior to integration was able to retrieve and save the data using hibernate but after adding c3p0 properties i am getting following errors.

java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:690)

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:1422)

.BasicResourcePool] com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@1e01d652 -- 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). Last acquisition attempt exception:
java.lang.NullPointerException

at oracle.jdbc.driver.OracleDriver.acceptsURL(OracleDriver.java:931)
at java.sql.DriverManager.getDriver(DriverManager.java:268)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:240)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:131)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:156)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:145)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
2014-04-30 16:28:56,361 [C3P0PooledConnectionPoolManager[identityToken->1hgesw6911e17f2m1dl7vmr|264d40df]-HelperThread-#1] WARN [com.mchange.v2.resourcepool.BasicResourcePool] Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5631db04 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.

Existing configuration with JNDI (working)

<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/ArticleWorksDS</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<mapping class="com.abc.aw.persistence.po.User"/>
<mapping class="com.abc.aw.persistence.po.UserAccess"/>

New Configuration with JNDI (Not working):
<property name="hibernate.connection.datasource">java:comp/env/jdbc/ArticleWorksDS</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>


<!--JDBC c3p0 connection pool -->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.timeout">3600</property>

<mapping class="com.abc.aw.persistence.po.User"/>
<mapping class="com.abc.aw.persistence.po.UserAccess"/>

If I add user name and password details without using JNDI in hibernate-cfg.xml its working fine.

New Configuration without JNDI (working):
<property name="hibernate.connection.url">jdbc:oracle:thin:@richtestdb02:1521:devrpmrt</property>
<property name="hibernate.connection.username">article_works</property>
<property name="hibernate.connection.password">article_worksdev</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>


<!--JDBC c3p0 connection pool -->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.timeout">3600</property>

<mapping class="com.abc.aw.persistence.po.User"/>
<mapping class="com.abc.aw.persistence.po.UserAccess"/>


Context.xml:

<Context>
<Resource name="jdbc/ArticleWorksDS"
type="oracle.jdbc.pool.OracleDataSource"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@richtestdb02:1521:devrpmrt"
validationQuery="SELECT 1 FROM SHOPPER"
userName="article_works"
password="article_worksdev"
maxActive="20"
maxIdle="10"
maxWait="-1" />
</Context>


New Jars added to configure c3p0 :
c3p0-0.9.5-pre8.jar
mchange-commons-java-0.2.7.jar

Can any one provide solution to resolve above errors?? Any pointers would help,thank you


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

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.