Atomikos Forum

Atomikos+Hibernate on container level -- lots of libs?

Guys,

I am in the process of integrating Hibernate and Atomikos. My resource is managed by the Tomcat container in the context.xml.

 <Resource auth="Container" factory="com.atomikos.tomcat.BeanFactory"
        maxPoolSize="120" minPoolSize="5" name="jdbc/MNA_XA_Managed"
        testQuery="select 1 from dual" type="com.atomikos.jdbc.AtomikosDataSourceBean"
        uniqueResourceName="AtomikosDataSourceJDBCOracle.MNA"
        xaDataSourceClassName="oracle.jdbc.xa.client.OracleXADataSource"
        xaProperties.URL="..."
        xaProperties.password="..." xaProperties.user="..." />

The following properties are defined in my Hibernate SessionFactory:

<property name="hibernateProperties">
    <props>
        <prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory
        </prop>
        <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
        </prop>
        <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
...            
</property>

When I launch my web app, it seems like a lot of libraries need to be present in my tomcat/lib directory in order for the application to work. Below is a list of libraries that I needed to move from my application's WEB-INF/lib directory to the tomcat/lib directory.

Is this all really necessary? Or did I do something wrong?

commons-collections-3.2.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
ejb3-persistence-1.0.2.GA.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-core-3.3.2.GA.jar
javassist-3.14.0-GA.jar
jta.jar
ojdbc6-11.1.0.7.0.jar
orai18n.jar
slf4j-api-1.6.0.jar
transactions.jar
transactions-api.jar
transactions-hibernate3.jar
transactions-jdbc.jar
transactions-jms.jar
transactions-jta.jar
transactions-osgi.jar
Rik Gruwez (2) Send private email
Tuesday, June 14, 2011
 
 
Rik,

If you have the JTA support at container level then the jta.jar and transactions-*.jar need to be in common/lib

However, not sure about the hibernate jars and dependencies. Do you have the hibernate config also at tomcat root level?
Guy Pardon Send private email
Tuesday, June 14, 2011
 
 
Hi Guy,
I was aware of the jta and transaction* dependencies. The reason I now all of a sudden have a lot of Hibernate dependencies in the Tomcat container to Hibernate thingies is because I tried to implement the workaround suggested in this JIRA:
https://jira.springsource.org/browse/SPR-1976

The HibernateConnectionDataSource class suggested by this Jira issue as a workaround introduces those Hibernate dependencies. So it is not really an option when you want to keep a lightweight Tomcat. :-(
Rik Gruwez (2) Send private email
Wednesday, June 15, 2011
 
 
Guy,
Upon further investigation, it turns out that the entire array of Hibernate dependencies are introduced by the following entries in the hibernateProperties of the sessionFactory:

<prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>    

These two properties are mentioned in the "Hibernate Integration" page http://www.atomikos.com/Documentation/HibernateIntegration

It seems odd to me that I would have to include the entire Hibernate stack in my J2EE container when I define my datasource as a resource in Tomcat.

Your thoughts?

Regards,
Rik
Rik Gruwez (2) Send private email
Thursday, June 16, 2011
 
 
One more thing...
Looking at the source code of com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory, I see the following comment:

"Atomikos-specific JTATransactionFactory implementation that does not rely on JNDI for standalone (JNDI-less) deployments."

What I try to do is use the Atomikos transaction manager at Tomcat level. My WARs use Spring+Hibernate, so that is where I would like Hibernate to use the Atomikos transaction manager.
Rik Gruwez (2) Send private email
Thursday, June 16, 2011
 
 
I see. Maybe you could try the following:

-placing hibernate jars at the war level (WEB-INF/lib)
-doing the same for transactions-hibernate3.jar

That should fix it?

HTH
Guy Pardon Send private email
Thursday, June 16, 2011
 
 
Hi Guy,
Indeed, this solves the problem. Thanks a lot for the tip!
Regards,
Rik
Rik Gruwez (2) Send private email
Thursday, June 16, 2011
 
 
No problem:-) Can I ask one favor in return: if you could document this in our Tomcat/Hibernate integration pages on the wiki at http://www.atomikos.com/Documentation ?

I would do it, but I think it is best if you have a go first because you experienced the problem and hence know where/how to formulate things...

Thanks
Guy Pardon Send private email
Thursday, June 16, 2011
 
 
I tried to modify the wiki but got the following error:

... has no permission to CHANGE Hibernate Integration.
Rik Gruwez (2) Send private email
Thursday, June 16, 2011
 
 
Sorry about that; please email your Wiki user name to webmaster at atomikos dot com

Thanks
Guy Pardon Send private email
Thursday, June 16, 2011
 
 
Hello

FYI the Hibernate/JPA/Atomikos integration is also well documented on this article:
http://alexandros-karypidis.blogspot.com/2011/06/integrating-jetty-spring-aspectj-wicket.html
Frederic Conrotte Send private email
Monday, July 04, 2011
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics