Atomikos Forum |
|
Hi fellows, how're u doing?!! ;-)))
I'm newbie to Atomikos (anyway to XA/JPA Transactions) and I've been setting an App. w/ rebinding both XADataSource and UserTransaction in JNDI and lookUp upon Spring/JPA and in the log I get the above message (No JTA TransactionManager found: transaction suspension not available) : what does it means??! In the the case of any fail, the transaction will not be Rollbacked??! (any tip an information are welcome!) Tnx in advance,
Ok, so that´s my setup:
<!-- EntityManagerFactory <- DataSource de Container Java(Se há + de 1 PU no persistence.xml, o nome da PU deve ser determinado em persistenceUnitName).--> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <!-- esta setting p/ ser usada em Produção: DataSource de Container Java.--> <!--property name="dataSource" ref="dataSource"></property--> <property name="persistenceUnitName" value="agendaJPAdsJTA-jarPU" /><!-- agendaJPAds-jarPU--> <property name="jpaPropertyMap"> <map> <entry key="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/> <!--entry key="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/ -falha no Excluir - --> <entry key="hibernate.transaction.flush_before_completion" value="true"/> <entry key="hibernate.transaction.auto_close_session" value="true"/> <entry key="hibernate.current_session_context_class" value="jta"/> <entry key="hibernate.connection.release_mode" value="auto"/> </map> </property> <!-- custom implementation p/ enriquecer o PersistenceUnitInfo read from the persistence.xml JPA configuration file with the JTA DataSource, specifying the JTA datasource directly in the Spring configuration file has the advantage that we can use a direct reference to the datasource instead of using a JNDI name as requied by the jta-data-source setting in the persistence.xml file --> <!--property name="persistenceUnitPostProcessors"> <list> <!- - Obs.: a Classe deste Objeto, "JtaPersistenceUnitPostProcessor", deve ser definida na App.- -> <bean class="JtaPersistenceUnitPostProcessor"> <property name="jtaMode" value="true"></property> <property name="jtaDataSource" ref="dataSource"></property> </bean> </list> </property--> <!-- customização do JPA Provider (neste caso o Hibernate). --> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="true" /> <property name="generateDdl" value="false" /> <!--property name="database" value="MYSQL" /--> <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" /> </bean> </property> </bean> <!-- JTA/XA Transaction Manager -> setup p/ Produção: DataSource de Container Java.--> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="userTransaction" ref="transaction" /> </bean> <!-- userTransaction obtido via Lookup JNDI (Importante: lembrar definir (user)TransactionManager no TomCat).--> <bean id="transaction" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="resourceRef" value="true" /> <property name="cache" value="true" /> <property name="jndiName"> <value>java:comp/UserTransaction</value> </property> </bean> <!-- Instrui o Spring a realizar gerenciamento transacional declarativo automático nas classes anotadas.--> <tx:annotation-driven/> <!-- PostProcessors para realizar injeção de recursos de acordo com a especificação JPA (@PersistenceContext, @PersistenceUnit). --> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <!-- PostProcessors para realizar a conversão de exceções nas classes @Repository (das exceções nativas como JPA PersistenceExceptions to Spring's DataAccessException). --> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> and now, some snippet log: INFO: Second-level cache: enabled 08/02/2011 19:52:02 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query cache: disabled 08/02/2011 19:52:02 org.hibernate.cfg.SettingsFactory ... INFO: Check Nullability in Core (should be disabled when Bean Validation is on): enabled 08/02/2011 19:52:03 org.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory 08/02/2011 19:52:04 org.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: Not binding factory to JNDI, no JNDI name configured 08/02/2011 19:52:04 org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization INFO: Bean 'entityManagerFactory' of type [class org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 08/02/2011 19:52:04 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@14a18d: defining beans [entityManagerFactory,transactionManager,transaction,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,usuarioServiceFcd,contatoRepo,enderecoRepo,meioContatoRepo,usuarioRepo,usuario,contato,contatoServiceFcd,endereco,enderecoServiceFcd,meioContato,meioContatoServiceFcd]; root of factory hierarchy 08/02/2011 19:52:05 org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager<b> INFO: Using JTA UserTransaction: com.atomikos.icatch.jta.UserTransactionImp@14a97b 08/02/2011 19:52:05 org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager</b> AVISO: No JTA TransactionManager found: transaction suspension not available 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: <b>createCompositeTransaction ( 10000 ): created new ROOT transaction with id 172.25.0.39.tm0000200029</b> 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@8d0b0f ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: <b>addParticipant ( XAResourceTransaction: 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.start ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 , XAResource.TMNOFLAGS ) on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@c944267f ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.end ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 , XAResource.TMSUCCESS ) on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@6b93c5 ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: commit() done (by application) of transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.prepare ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 ) returning OK on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.commit ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 , false ) on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396</b> 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: afterCompletion ( <b>STATUS_COMMITTED</b> ) called on Synchronization: org.hibernate.ejb.EntityManagerImpl$1@17e60a1 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: <b>afterCompletion ( STATUS_COMMITTED ) called on Synchronization: org.hibernate.transaction.synchronization.HibernateSynchronizationImpl@1f9f0f2</b> 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println Doesn't it mean: the transaction is really sucessfull and the commit was in deed confirmed??! (tnx again for replying! ;-))
Oh, (I just forget to feed..)
and now some snippet JUnit Test Log: 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: createCompositeTransaction ( 10000 ): created new ROOT transaction with id 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@8d0b0f ) for transaction 172.25.0.39.tm0000200029 Hibernate: insert into usuario (login, nome, senha) values (?, ?, ?) 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: addParticipant ( XAResourceTransaction: 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.start ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 , XAResource.TMNOFLAGS ) on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@c944267f ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.end ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 , XAResource.TMSUCCESS ) on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@6b93c5 ) for transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:05 com.atomikos.diagnostics.Slf4jConsole println INFO: commit() done (by application) of transaction 172.25.0.39.tm0000200029 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.prepare ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 ) returning OK on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: XAResource.commit ( 3137322E32352E302E33392E746D30303030323030303239:3137322E32352E302E33392E746D32 , false ) on resource jdbc/agendaXA-DS represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@f47396 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: afterCompletion ( STATUS_COMMITTED ) called on Synchronization: org.hibernate.ejb.EntityManagerImpl$1@17e60a1 08/02/2011 19:52:06 com.atomikos.diagnostics.Slf4jConsole println INFO: afterCompletion ( STATUS_COMMITTED ) called on Synchronization: org.hibernate.transaction.synchronization.HibernateSynchronizationImpl@1f9f0f2
OK I think it is this:
You configure Spring to lookup the UserTransaction in JNDI. Our UserTransaction impl in pre-3.7 releases does NOT also implement TransactionManager, so Spring has no way to deal with suspends (defined on the TransactionManager). Possible solutions: -use Spring config without JNDI (cf our documentation wiki) or -use 3.7 or higher Best
But, my version is: Release 3.7.0M5
Could u plz explain me what's the meaning of "a transaction be suspended??! So, anyway (w/ the setup the way it is now) if I receive a COMMITED (in log) the operations really were shot and really happend in the resource (dataBase)??! And in the caso of any constraint/exception the Trasaction Manager will be able to proporly "storn" (RollBack) the operations??! |