Atomikos Forum

All feedback will be investigated, but priority support, confidential support, and product priority updates are reserved for customers. Interested in becoming a customer? Subscribe here...

Only registered users can post (registration is free). Problems registering? Send an email to support@atomikos.com to get help.


Hibernate warning: "Cannot join transaction"

Hi,

I'm trying to configure Hibernate to use Atomikos as the transaction manager. The documentation states so set the Hibernate parameters:

transaction.manager_lookup_class=com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
transaction.factory_class=com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory

But when I run my application, the log contains lots of warnings like:
Cannot join transaction: do not override hibernate.transaction.factory_class

I searched this forum and found a couple of topics like
http://fogbugz.atomikos.com/default.asp?community.6.1085.2#discussTopic1086
but none of them have a solution. To get rid of these warnings, I changed "transaction.factory_class" to "org.hibernate.ejb.transaction.JoinableCMTTransactionFactory".

I'm not sure if this is the right solution. If it was, what's the purpose of Atomikos' transaction factory anyway?

It is a bit frustrating because this ia the very basic configuration of JPA/Hibernate and I cannot get it to run smoothly.

Versions:
- Atomikos Transactions Essentials 3.6.4
- Hibernate 3.5.0-Final (tried 3.3.2 before - same result)
- Spring 3.0.2
- JDK 1.6.0_19

Thanks in advance!
Stephan
Stephan Vollmer Send private email
Tuesday, April 13, 2010
 
 
Hi,

Yes, recent versions of Hibernate have some extra JNDI dependencies (JBoss is an appserver vendor, not sure if that is the reason;-) We are working on that.

Spring's LocalSessionFactory also has a setJtaTransactionManager injector method. Might be an alternative for the time being?

HTH
Guy Pardon Send private email
Tuesday, April 13, 2010
 
 
Hi,

thanks for your fast response! Unfortunately, I cannot use the setJtaTransactionManager method because I use JPA and Spring's LocalContainerEntityManagerFactoryBean that does not have this method.

Until a new version of Atomikos is released, is it ok to use the JoinableCMTTransactionFactory?

Cheers,
Stephan
Stephan Vollmer Send private email
Wednesday, April 14, 2010
 
 
Hi,

Hard to say.

If this is for production use, I strongly recommend our 'developer access' support formula to have us assist you one-on-one and make sure things work like you expect them to.

Best
Guy
Guy Pardon Send private email
Wednesday, April 14, 2010
 
 
I am using Spring 3.0.2 + Hibernate 3.5.0-Final in JPA Mode.
All i had to set is transaction.manager_lookup_class, the Factory does not need to be specified - it should work without (i did not face any problem yet let hibernate use its own default jta factory here - must not be "true" in any case, but give it a try).
Torsten Krah Send private email
Thursday, April 15, 2010
 
 
Not sure if I agree here - according to the Hibernate sources, the default Hibernate transaction factory will not work properly. At least: I don't see how it can use Atomikos because it cannot find our JTA objects. So I would suspect that you're not really using JTA for the Hibernate JDBC access...
Guy Pardon Send private email
Thursday, April 15, 2010
 
 
I did not specify any factory - but looking at hibernate debug output it show this:

2010-04-15 14:46:40,736 [main]          INFO  org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
2010-04-15 14:46:40,738 [main]          INFO  org.hibernate.transaction.TransactionManagerLookupFactory - instantiating TransactionManagerLookup: com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
2010-04-15 14:46:40,740 [main]          INFO  org.hibernate.transaction.TransactionManagerLookupFactory - instantiated TransactionManagerLookup

So it uses the JoinableCMTTransactionFactory by default - which seems to work - shouldn't it?

2010-04-15 14:46:42,520 [main]          DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - Looking for a JTA transaction to join
2010-04-15 14:46:42,531 [main]          DEBUG org.hibernate.jdbc.JDBCContext - successfully registered Synchronization

So its actually using the JTA Transaction already there.
Torsten Krah Send private email
Thursday, April 15, 2010
 
 
@Torsten:

I don't really see the JTA transaction itself in your log excerpt - so I am still not sure.
Guy Pardon Send private email
Thursday, April 15, 2010
 
 
Some more about inserting one JPA Entity:

2010-04-15 16:07:34,926 [main]          INFO  org.springframework.transaction.jta.JtaTransactionManager - Using JTA UserTransaction: com.atomikos.icatch.jta.J2eeUserTransaction@2fa847df
2010-04-15 16:07:34,926 [main]          INFO  org.springframework.transaction.jta.JtaTransactionManager - Using JTA TransactionManager: com.atomikos.icatch.jta.UserTransactionManager@510699ea
2010-04-15 16:07:35,244 [Thread-3]      INFO  atomikos - MessageConsumerSession: Starting JMS listener thread.
2010-04-15 16:07:35,263 [Thread-3]      INFO  atomikos - AtomikosConnectionFactoryBean 'jmsFactory1': createConnection()...
2010-04-15 16:07:35,263 [Thread-3]      INFO  atomikos - AtomikosConnectionFactoryBean 'jmsFactory1': init...
2010-04-15 16:07:35,263 [Thread-3]      INFO  atomikos - AtomikosConnectionFactoryBean 'jmsFactory1': getReference()...
2010-04-15 16:07:35,265 [Thread-3]      INFO  atomikos - AtomikosConnectionFactoryBean 'jmsFactory1': initializing with [ xaConnectionFactory=org.apache.activemq.ActiveMQXAConnectionFactory@2569a1c5, xaConnectionFactoryClassName=null, uniqueResourceName=jmsFactory1, maxPoolSize=10, minPoolSize=1, borrowConnectionTimeout=30, maxIdleTime=60, reapTimeout=0, maintenanceInterval=60, xaProperties=[], localTransactionMode=false]
2010-04-15 16:07:35,280 [main]          INFO  atomikos - createCompositeTransaction ( 900000 ): created new ROOT transaction with id com.atomikos.spring.jdbc.tm-dev0000100069
2010-04-15 16:07:35,321 [main]          DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12713404552
2010-04-15 16:07:35,321 [main]          DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - Looking for a JTA transaction to join
2010-04-15 16:07:35,325 [main]          DEBUG org.hibernate.jdbc.JDBCContext - successfully registered Synchronization
2010-04-15 16:07:35,343 [main]          DEBUG org.hibernate.event.def.AbstractSaveEventListener - executing identity-insert immediately
2010-04-15 16:07:35,344 [main]          DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2010-04-15 16:07:35,344 [main]          DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2010-04-15 16:07:35,344 [main]          DEBUG org.hibernate.SQL - insert into TestEntity (id, text, value) values (null, ?, ?)
2010-04-15 16:07:35,346 [main]          INFO  atomikos - AtomikosDataSoureBean 'h2jdbc': getConnection ( null )...
2010-04-15 16:07:35,346 [main]          INFO  atomikos - AtomikosDataSoureBean 'h2jdbc': init...
2010-04-15 16:07:35,346 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: calling toString...
2010-04-15 16:07:35,346 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: calling toString...
2010-04-15 16:07:35,346 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: calling getAutoCommit...
2010-04-15 16:07:35,351 [main]          INFO  atomikos - addParticipant ( XAResourceTransaction: 636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657630303030313030303639:636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657631 ) for transaction com.atomikos.spring.jdbc.tm-dev0000100069
2010-04-15 16:07:35,351 [main]          INFO  atomikos - XAResource.start ( 636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657630303030313030303639:636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657631 , XAResource.TMNOFLAGS ) on resource h2jdbc represented by XAResource instance xads0: url=jdbc:h2:mem:h2TestDB;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE user=h2TestDB
2010-04-15 16:07:35,352 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: calling prepareStatement...
2010-04-15 16:07:35,354 [main]          DEBUG org.hibernate.id.IdentifierGeneratorHelper - Natively generated identity: 1
2010-04-15 16:07:35,355 [main]          DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2010-04-15 16:07:35,355 [main]          DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
2010-04-15 16:07:35,355 [main]          DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2010-04-15 16:07:35,355 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: calling getWarnings...
2010-04-15 16:07:35,355 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: calling clearWarnings...
2010-04-15 16:07:35,484 [main]          INFO  atomikos - atomikos connection proxy for conn1: url=jdbc:h2:mem:h2TestDB user=H2TESTDB: close()...
2010-04-15 16:07:35,485 [main]          INFO  atomikos - XAResource.end ( 636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657630303030313030303639:636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657631 , XAResource.TMSUCCESS ) on resource h2jdbc represented by XAResource instance xads0: url=jdbc:h2:mem:h2TestDB;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE user=h2TestDB
2010-04-15 16:07:35,487 [main]          DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
2010-04-15 16:07:35,488 [main]          DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
2010-04-15 16:07:35,491 [main]          DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2010-04-15 16:07:35,492 [main]          DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2010-04-15 16:07:35,493 [main]          DEBUG org.hibernate.pretty.Printer - listing entities:
2010-04-15 16:07:35,493 [main]          DEBUG org.hibernate.pretty.Printer - de.sf.model.TestEntity{id=1, text=null, value=1}
2010-04-15 16:07:35,493 [main]          DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
2010-04-15 16:07:35,494 [main]          INFO  atomikos - commit() done (by application) of transaction com.atomikos.spring.jdbc.tm-dev0000100069
2010-04-15 16:07:35,498 [Atomikos:3]    INFO  atomikos - XAResource.prepare ( 636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657630303030313030303639:636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657631 ) returning OK on resource h2jdbc represented by XAResource instance xads0: url=jdbc:h2:mem:h2TestDB;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE user=h2TestDB
2010-04-15 16:07:35,517 [Atomikos:3]    INFO  atomikos - XAResource.commit ( 636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657630303030313030303639:636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D2D64657631 , false ) on resource h2jdbc represented by XAResource instance xads0: url=jdbc:h2:mem:h2TestDB;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE user=h2TestDB
2010-04-15 16:07:35,520 [main]          INFO  atomikos - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: org.compass.gps.device.hibernate.embedded.CompassEventListener$CompassEmbeddedSyncronization@4e26d560
2010-04-15 16:07:35,520 [main]          INFO  atomikos - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: org.hibernate.ejb.AbstractEntityManagerImpl$1@5782b9b5
2010-04-15 16:07:35,575 [main]          INFO  atomikos - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: org.compass.core.transaction.JTASyncTransaction$JTATransactionSynchronization@4eff0d4b
2010-04-15 16:07:35,575 [main]          INFO  atomikos - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: org.hibernate.transaction.CacheSynchronization
2010-04-15 16:07:35,576 [main]          DEBUG org.hibernate.ejb.EntityManagerImpl - Closing entity manager after transaction completion
2010-04-15 16:07:35,577 [main]          INFO  atomikos - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: org.hibernate.ejb.EntityManagerImpl$1@7da2467a


Looking at the CMT Factory it has access to the Atomikos JTA objects throught the configured TransactionManager (via TransactionManagerLookup).
The Trace above seems ok to me - so actual imho i am using Hibernate + JTA via Atomikos without configuring the JTA Factory for hibernate.
Torsten Krah Send private email
Thursday, April 15, 2010
 
 
Looks ok indeed - although I am not sure why.

In any case, I have fixed (I think) the original problem in our AtomikosJTATransactionFactory also. To be out soon.

Thanks
Guy Pardon Send private email
Thursday, April 15, 2010
 
 
Looking here:

http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/transactions.html

5.2.2 Using JTA

[...]
It is important to let Hibernate EntityManager define the hibernate.transaction.factory_class (ie not overriding this value). Remember to also set org.hibernate.transaction.manager_lookup_class.
[...]

So imho in a CMT environment (meaning hibernate does not control the transaction but someone else - e.g. using JTA via Atomikos) the factory must not be overridden anymore. It enough to set the TxManager-Lookup Class to get things running (and it seems to work).
Torsten Krah Send private email
Thursday, April 15, 2010
 
 
Looks like you are right.

Thanks a lot! I have updated the documentation in the Wiki to reflect this.
Guy Pardon Send private email
Thursday, April 15, 2010
 
 

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

Other recent topics Other recent topics
 
Powered by FogBugz