Atomikos Forum

Atomikos TransactionEssentials and Hibernate Envers and JPA 2.0

Hi,

We would like use Atomikos TransactionEssentials with our application based on Spring and JPA (Hibernate impl) along with Tomcat 6. Everything looks fine with transactions management (tested with an additional JMS resource).

We have one problem we can't fix. It looks like transactions inside which we are changing one of @Audited entities are always rolled-back. So basically we can't use Envers along with Atomikos TransactionEssentials at the moment.

We're using:
 - Atomikos Essentials 3.6.5
 - Hibernate 3.6.4.Final (as JPA implementation)
 - Hibernate Envers 3.6.4.Final
 - Spring 3.0.3.RELEASE
 - Spring web flow - 2.3.0.RELEASE
 

Our configuration:

    --- SPRING CONFIGURATION ---

    <bean id="atomikosTransactionManager"
        class="com.atomikos.icatch.jta.UserTransactionManager"
        init-method="init"
        destroy-method="close" >
        <property name="forceShutdown" value="false" />
    </bean>

    <bean id="atomikosUserTransaction"
        class="com.atomikos.icatch.jta.UserTransactionImp">
        <property name="transactionTimeout" value="1800" />
    </bean>

    <bean id="transactionManager"
        class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" ref="atomikosTransactionManager" />
        <property name="userTransaction" ref="atomikosUserTransaction" />
        <qualifier value="jta" />
    </bean>


    <bean id="MysqlDataSourceParent" abstract="true"
        class="com.atomikos.jdbc.AtomikosDataSourceBean">
        <property name="xaDataSourceClassName"
            value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
        <property name="uniqueResourceName" value="ourMainDatasource" />
        <property name="maxPoolSize" value="${db.maxActive}" />
        <property name="minPoolSize" value="${db.initialSize}" />
        <property name="reapTimeout" value="300" />
        <property name="testQuery" value="${db.validationQuery}" />
        
        <property name="xaProperties">
            <props>
                <prop key="user">${repository-beans.MySqlDataSource.username}</prop>
                <prop key="password">${repository-beans.MySqlDataSource.password}</prop>
                <prop key="url">${repository-beans.MySqlDataSource.url}</prop>
                <prop key="pinGlobalTxToPhysicalConnection">true</prop>
            </props>
        </property>
    </bean>


    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

        <property name="dataSource" ref="MysqlDataSource" />
        <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
        <property name="jpaVendorAdapter" ref="MysqlJpaVendorAdapter" />

        <property name="jpaProperties">
            <props>
                <!-- Hibernate Search / Lucene -->
                <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
                </prop>
                <prop key="hibernate.connection.isolation">3</prop>
                  <prop key="hibernate.current_session_context_class">jta</prop>                 

            </props>
        </property>
    </bean>


    --- PERSITENCE.XML ---
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">

    <persistence-unit name="application" transaction-type="JTA">



        <properties>
                  <property name="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup" />
                  <property name="hibernate.current_session_context_class" value="jta" />
                  <property name="hibernate.connection.isolation" value="3" />
                 
                 
            <property name="hibernate.hbm2ddl.auto" value="${persistence.xml.hibernate.hbm2ddl.auto}" />
            <property name="hibernate.format_sql" value="false" />


            <property name="org.hibernate.envers.audit_table_suffix" value="${hibernate.envers.audit_table_suffix}" />
            <property name="org.hibernate.envers.revision_field_name" value="${hibernate.envers.revision_field_name}" />
            <property name="org.hibernate.envers.store_data_at_delete" value="true" />            

            
        </properties>

    </persistence-unit>
</persistence>


Stack trace:
org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: The transaction was set to rollback only
    at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1013)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
    at no.mintra.trainingportal.interfaces.web.admin.courses.course.dashboard.about.show.CourseAboutShowController$$EnhancerByCGLIB$$6f091632.updateCoursePublishStatus(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at no.mintra.trainingportal.interfaces.web.logging.response.ResponseTimeLoggerFilter.doFilter(ResponseTimeLoggerFilter.java:42)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at no.mintra.trainingportal.interfaces.web.logging.mdc.MDCFilter.doFilter(MDCFilter.java:43)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at no.mintra.trainingportal.interfaces.web.logging.session.HttpSessionSizeMonitoringFilter.doFilter(HttpSessionSizeMonitoringFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.terracotta.modules.tomcat.tomcat_5_5.SessionValve55.tcInvoke(SessionValve55.java:99)
    at org.terracotta.modules.tomcat.tomcat_5_5.SessionValve55.invoke(SessionValve55.java:85)
    at org.terracotta.session.ModernTomcatSessionValve.invoke(ModernTomcatSessionValve.java:66)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.transaction.RollbackException: The transaction was set to rollback only
    at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:312)
    at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:612)
    at com.atomikos.icatch.jta.UserTransactionImp.commit(UserTransactionImp.java:168)
    at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1010)
    ... 77 more
---------------------------------------------------------------------------------------------------------------------


If we will not fix this problem we will probably remove Atomikos or Envers or we will switch some application server.

I hope some can help with this problem because I like Atomikos which along with Tomcat and Spring gives us what we need (almost).

Regards
Marek Dominiak
Marek Dominisk Send private email
Tuesday, October 23, 2012
 
 
I forgot to attach transactions.properties:

com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.serial_jta_transactions=false
com.atomikos.icatch.max_actives=500
com.atomikos.icatch.enable_logging=false
com.atomikos.icatch.max_timeout=3600000
com.atomikos.icatch.default_jta_timeout=1800000

com.atomikos.icatch.log_base_dir=${atomikos.transaction.manager.log_base_dir}
Marek Dominisk Send private email
Tuesday, October 23, 2012
 
 

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

Other recent topics Other recent topics