0 Replies Latest reply on May 11, 2006 11:48 AM by Luigi Putanesca

    Why is StaleObjectStateException wrapped in IllegalArgumentE

    Luigi Putanesca Newbie

      I'm using JBoss 4.0.4CR2, EJB3 RC6. Whenever StaleObjectStateException is thrown, it comes wrapped in an IllegalArgumentException and I'm wondering why this is done. It's not a huge deal but just seems to make things unnecessarily inconvenient.

      The StaleObjectStateException is very meaningful while IllegalArgumentException is much less so and instead of just catching the exception I'm looking for, I have to catch a much wider variety and check the getCause() to see what really happened.

      Below is the actual stack trace:

      javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [net.lgsystems.org.organization.entity.User#<null>]
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at net.lgsystems.jboss.security.LgsRoleBasedAuthorizationInterceptor.invoke(LgsRoleBasedAuthorizationInterceptor.java:134)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
       at $Proxy175.saveUser(Unknown Source)
       at net.lgsystems.util.test.OptimisticLockingTest$TestThread.run(OptimisticLockingTest.java:91)
      Caused by: java.lang.IllegalArgumentException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [net.lgsystems.org.organization.entity.User#<null>]
       at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:205)
       at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181)
       at net.lgsystems.org.organization.mgr.UserMgrImpl.updateUser(UserMgrImpl.java:110)
       at net.lgsystems.org.organization.ejb.OrganizationManagementBean.saveUser(OrganizationManagementBean.java:76)
       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:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:168)
       at net.lgsystems.access.core.AccessInterceptor.process(AccessInterceptor.java:83)
       at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:120)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       ... 18 more
      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [net.lgsystems.org.organization.entity.User#<null>]
       at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:240)
       at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:99)
       at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
       at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:676)
       at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:660)
       at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:664)
       at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:202)
       ... 39 more
      20