Foros de discusión

Glassfish not rolling back Transactions

thumbnail
Laurent Gauthier, modificado hace 12 años.

Glassfish not rolling back Transactions

New Member Mensajes: 15 Fecha de incorporación: 3/02/10 Mensajes recientes
After extensive testing with Glassfish 3.0 and LR 6.0.6 (with MySQL) I still cannot configure the installation so that DB transactions that should be rolledback due to an exception are actually rolledback. The expected behavior is obtained in a similar setup with Tomcat with JTA (JOTM) and the same code and a very similar configuration in Glassfish (same database) rollbacks are just without any effect. We even tested this in an other environement with Glassfish 2 with the same results.

The following is a log trace on the GlassFish system with org.springframework.transaction in DEBUG level:

[#|2011-06-16T00:00:50.153+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,149 DEBUG [JtaTransactionManager:365] Creating new transaction with name [com.test.transaction.service.impl.FooLocalServiceImpl.addFooWithException]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-com.liferay.portal.kernel.exception.PortalException,-com.liferay.portal.kernel.exception.SystemException
|#]
[#|2011-06-16T00:00:50.155+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,154 DEBUG [JtaTransactionManager:415] Suspending current transaction, creating new transaction with name [com.liferay.counter.service.impl.CounterLocalServiceImpl.increment]
[#]
[#|2011-06-16T00:00:50.156+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,155 DEBUG [JtaTransactionManager:752] Initiating transaction commit
|#]
[#|2011-06-16T00:00:50.158+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,156 DEBUG [JtaTransactionManager:1015] Resuming suspended transaction after completion of inner transaction
|#]
[#|2011-06-16T00:00:50.196+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,192 INFO  [FooLocalServiceImpl:61] Created: {id=504, createdDate=Thu Jun 16 00:00:50 GMT 2011, description=Add with exception}
|#]
[#|2011-06-16T00:00:50.201+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,197 DEBUG [JtaTransactionManager:470] Participating in existing transaction
|#]
[#|2011-06-16T00:00:50.204+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,202 DEBUG [JtaTransactionManager:470] Participating in existing transaction
|#]
[#|2011-06-16T00:00:50.211+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,207 DEBUG [JtaTransactionManager:470] Participating in existing transaction
|#]
[#|2011-06-16T00:00:50.217+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,212 DEBUG [JtaTransactionManager:470] Participating in existing transaction
|#]
[#|2011-06-16T00:00:50.222+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,217 DEBUG [JtaTransactionManager:470] Participating in existing transaction
|#]
[#|2011-06-16T00:00:50.224+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,222 DEBUG [JtaTransactionManager:415] Suspending current transaction, creating new transaction with name [com.liferay.counter.service.impl.CounterLocalServiceImpl.increment]
|#]
[#|2011-06-16T00:00:50.226+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,224 DEBUG [JtaTransactionManager:752] Initiating transaction commit
|#]
[#|2011-06-16T00:00:50.227+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,226 DEBUG [JtaTransactionManager:1015] Resuming suspended transaction after completion of inner transaction
|#]
[#|2011-06-16T00:00:50.263+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,259 INFO  [FooLocalServiceImpl:67] Created: {activityId=804, groupId=10157, companyId=10132, userId=10169, createDate=1308182450202, mirrorActivityId=0, classNameId=13601, classPK=504, type=1, extraData=, receiverUserId=0}
|#]
[#|2011-06-16T00:00:50.268+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,264 DEBUG [JtaTransactionManager:843] Initiating transaction rollback
|#]
[#|2011-06-16T00:00:50.297+0000|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=39;_ThreadName=Thread-1;|00:00:50,269 INFO  [TransactionPortlet:59] 
com.liferay.portal.kernel.exception.SystemException: Kill transaction
	at com.test.transaction.service.impl.FooLocalServiceImpl.addFooWithException(FooLocalServiceImpl.java:74)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
...etc...


From the above code, everything seems normal, we are using the Glassfish connection and the JtaTransactionManager. We palyed with different configurations in the portla-ext.properties, the spring contexts and the Glassfish connection pool but none had any impact on the final behavior. Basically, we are configured as such:

     transaction.isolation.portal=2
    
    #transaction.manager.impl=org.springframework.orm.hibernate3.HibernateTransactionManager
    transaction.manager.impl=org.springframework.transaction.jta.JtaTransactionManager 

    transaction.manager.property.allowCustomIsolationLevels=true

    jdbc.default.jndi.name=jdbc/LiferayPool


We also added the following file in the classpath at META-INF/ext-spring.xml as others suggested it could help:

        <jee:jndi-lookup id="liferayDataSource" jndi-name="jdbc/LiferayPool" />
        <jee:jndi-lookup id="counterDataSource" jndi-name="jdbc/LiferayPool" />

	<tx:jta-transaction-manager />


From the log, these are taken into account and seem to work as expected but again, no impact.

We have a simple test setup (actually we reused and modified a portlet from another post) that we can share if anybody cares to try and reproduce the behavior.

In the LR Jira there are reports to similar problems that apparently are fixed in the trunk but the nature of the fix is not documented and not sure if we can backport the fix.

Anybody have similar experience with Glassfish? Anybody manged to fix this in Glassfish?