0 Replies Latest reply on Jul 19, 2012 10:23 AM by Stewart Gracie

    Error during JBoss6 database call - ARJUNA-12125 TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple

    Stewart Gracie Newbie

      Hey all, first time poster here so if ive posted incorrectly or in the wrong place, please let me know.

       

      Ive encountered a problem with JBoss6 while trying to select an entity from a MSSQL database. Whenever I attempt to pull data from tables with Byte arrays in them, which represent images, I get the following error:

       

      2012-07-19 14:50:46,262 WARN  [com.arjuna.ats.arjuna] (WorkerThread#3[10.120.170.146:61181]) ARJUNA-12125 TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffff0a80aad9:126a:5006d39f:24ea, org.hibernate.transaction.synchronization.HibernateSynchronizationImpl@22d29e >: javax.persistence.PersistenceException: error during managed flush

          at org.hibernate.ejb.AbstractEntityManagerImpl$3.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1072) [:3.6.0.Final]

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:122) [:3.6.0.Final]

          at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51) [:3.6.0.Final]

          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:97) [:6.0.0.Final]

          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:274) [:6.0.0.Final]

          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:94) [:6.0.0.Final]

          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:159) [:6.0.0.Final]

          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1158) [:6.0.0.Final]

          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:119) [:6.0.0.Final]

          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75) [:6.0.0.Final]

          at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:82) [:0.0.1]

          at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:255) [:0.0.1]

          at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:349) [:0.0.1]

          at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:209) [:0.0.1]

          at org.jboss.ejb3.tx2.aop.CMTTxInterceptorWrapper.invoke(CMTTxInterceptorWrapper.java:52) [:0.0.1]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) [:1.0.0.GA]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.aspects.remoting.ReplicantsManagerInterceptor.invoke(ReplicantsManagerInterceptor.java:56) [:1.0.1.GA]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) [:1.0.3]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:182) [:1.7.17]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) [:1.7.17]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67) [:1.7.17]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.17]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86) [:1.7.17]

          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:392) [:1.7.17]

          at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53) [:1.7.17]

          at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91) [jboss-aop.jar:2.2.1.GA]

          at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) [:1.0.1.GA]

          at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:898) [:6.0.0.Final]

          at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:791) [:6.0.0.Final]

          at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:744) [:6.0.0.Final]

          at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548) [:6.0.0.Final]

          at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234) [:6.0.0.Final]

      Caused by: java.lang.UnsupportedOperationException: Illegal attempt to edit read only item

          at org.hibernate.cache.infinispan.entity.ReadOnlyAccess.lockItem(ReadOnlyAccess.java:24) [:3.6.0.Final]

          at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:106) [:3.6.0.Final]

          at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) [:3.6.0.Final]

          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) [:3.6.0.Final]

          at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185) [:3.6.0.Final]

          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) [:3.6.0.Final]

          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) [:3.6.0.Final]

          at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) [:3.6.0.Final]

          at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383) [:3.6.0.Final]

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117) [:3.6.0.Final]

       

      The table structure is shown below:

      CREATE TABLE [dbo].[Images](

          [ImageId] [int] NOT NULL,

          [ImageDescription] [nvarchar](max) NOT NULL,

          [ImageFileName] [nvarchar](max) NOT NULL,

          [ImageBinary] [varbinary](max) NOT NULL,

          [ContentLength] [bigint] NOT NULL,

          [ContentType] [nvarchar](max) NOT NULL,

          [DateAdded] [datetime] NOT NULL,

      CONSTRAINT [PK_Images] PRIMARY KEY CLUSTERED

       

      and the entity is defined as follows:

       

      @Entity

      @Table(name = "Images")

      @NamedQueries({

          @NamedQuery(name = "Image.findAll",

          query = "SELECT m FROM Images m",

          hints = {

              @QueryHint(name = "org.hibernate.cacheable", value = "true"),

              @QueryHint(name = "org.hibernate.cacheRegion", value = "local-query-cache-region-B")})

      })

      @Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "entity-cache-region-B")

      public class Images implements Serializable {

       

          private static final long serialVersionUID = 1L;

          @Id

          @Column(name = "ImageId", nullable = false)

          private Integer imageId;

          @Column(name = "ImageDescription", nullable = false)

          private String imageDescription;

          @Column(name = "ImageFileName", nullable = false)

          private String imageFileName;

          @Column(name = "ImageBinary", nullable = false)

          private Byte[] imageBinary;

          @Column(name = "ContentLength", nullable = false)

          private Integer contentLength;

          @Column(name = "ContentType", nullable = false)

          private String contentType;

          @Column(name = "DateAdded", nullable = false)

          @Temporal(TemporalType.TIMESTAMP)

          private Date datedAdded;

       

      with all setters, getters etc.

       

      The only way I have found to get around this error is when pulling the entity from the database, I use EntityManager.clear().

       

      Does anyone know why I would be getting this error? This code works on JBoss4 without the need for the clear() call and im in the progress of migrating it all to JBoss6.

       

      If you need further information, please let me know and ill do my best to update this post.

       

      Thanks

      Stewart