-->
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: Multi tenancy in Hibernate using jta-data-source
PostPosted: Thu Feb 06, 2014 12:48 pm 
Newbie

Joined: Tue Feb 04, 2014 7:17 am
Posts: 4
I was able to get multi tenancy to work as explained in the link https://docs.jboss.org/hibernate/core/4.2/devguide/en-US/html/ch16.html

I use EJB3 and Hibernate.

I specify the persistence properties in persuatance.xml.

I am able to set up a connection only if I specify hibernate specific properties i.e.
Code:
    <property name="hibernate.connection.username" value="system" />
    <property name="hibernate.connection.password" value="password" />
    <property name="hibernate.connection.url"   value="jdbc:simon:oracle:thin:@127.0.0.1:1521:xe" />
    <property name="hibernate.connection.driver_class" value="org.javasimon.jdbc4.Driver" />


If I specify a JNDI data source - then I am not able to get a connection. e.g:
Code:
<jta-data-source>java:/OcelotDS</jta-data-source>


With the above, the exception I get is
Code:
16:18:59,426 WARN  [com.mchange.v2.resourcepool.BasicResourcePool] (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4bc89815 -- 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.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:264) [rt.jar:1.6.0_38]
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:119) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:143) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:132) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) [c3p0-0.9.1.2.jar:0.9.1.2]
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) [c3p0-0.9.1.2.jar:0.9.1.2]

16:18:59,430 ERROR [stderr] (http-/0.0.0.0:8080-2) java.sql.SQLException: Connections could not be acquired from the underlying database!

16:18:59,431 ERROR [stderr] (http-/0.0.0.0:8080-2)  at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)

16:18:59,431 ERROR [stderr] (http-/0.0.0.0:8080-2)  at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)

16:18:59,431 ERROR [stderr] (http-/0.0.0.0:8080-2)  at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)

16:18:59,432 ERROR [stderr] (http-/0.0.0.0:8080-2)  at org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:84)

16:18:59,432 ERROR [stderr] (http-/0.0.0.0:8080-2)  at com.lombardrisk.util.multitenancy.MultiTenantProvider.getAnyConnection(MultiTenantProvider.java:58)

16:18:59,433 ERROR [stderr] (http-/0.0.0.0:8080-2)  at com.lombardrisk.util.multitenancy.MultiTenantProvider.getConnection(MultiTenantProvider.java:79)


The connection class is of type: C3P0ConnectionProvider org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider

Does this mean - this provider only accepts connection details as hibernate properties
and will not take JNDI Datasource?

regards, D


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.