We have been having an issue with this for quite some time, and I am battling to understand the cause of the issue, hoping someone could help explain and work a solution for this.
While using a web application an exception occassionally occurs:
2010-09-30 14:12:27,901 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/]] (ajp-0.0.0.0-8009-2) Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.mycompany.web.common.client.model.rank.RankResponse com.mycompany.web.common.client.rpc.Ranking
Service.rank(java.lang.String,int,com.mycompany.web.common.client.model.rank.RankRequestProperties,java.util.Map,java.util.Map,java.util.Map,java.util.Map)' threw an unexpected exception: javax.ejb.EJBTransactionRolledbackException: Transaction rolled back
Just prior to that in the log, the following is seen:
2010-09-30 14:12:27,895 WARN [org.jboss.cache.interceptors.OptimisticTxInterceptor] (ajp-0.0.0.0-8009-2) Caught exception, will now set transaction to roll back
org.jboss.cache.optimistic.DataVersioningException: Transaction attempted to create /adonis/org/hibernate/cache/StandardQueryCache/QUERY/sql: select <QUERY DETAILS>; max rows: 2 anew. It has already been created since this transaction started, by another (possibly remote) transaction.
We have a concurrent creation event.
at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.visitOptimisticPrepareCommand(OptimisticValidatorInterceptor.java:116)
....
2010-09-30 14:12:27,897 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (ajp-0.0.0.0-8009-2) [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@493ee8c1
org.jboss.cache.optimistic.DataVersioningException: Transaction attempted to create /adonis/org/hibernate/cache/StandardQueryCache/QUERY/sql: select <QUERY DETAILS>; max rows: 2 anew. It has already been created since this transaction started, by another (possibly remote) transaction.
We have a concurrent creation event.
at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.visitOptimisticPrepareCommand(OptimisticValidatorInterceptor.java:116)
Environment:
The application is deployed in an ear with an ejb and war component.
The ejb has a persistence unit, which uses an XA jta-datasource and 3 entity jar-files defined (that are deployed independantly)
Another application is deployed that the primary application depends on, an EAR with ejb and persistence. The persistence unit references a different XA datasource and references 1 of the 3 jar-files as above.
The issue might be caused by having 2 persistence contexts being applied to a single entity, but not entirely sure on this though
I have tried adjusting the transaction manger's configuration to allowMultipleLastResources = true (before we switched to XA datasources, this was necessary with tx datasources and this environment), but the error occurs with this enabled or disabled.
I am not sure whether this is a jboss cache issue, hibernate or transaction manager issue.
how could I avoid this issue? (the exception occurs irregularly, it's difficult to reproduce).