1 Reply Latest reply on Sep 18, 2014 5:43 PM by Scott Marlow

    Issue with JPA Transactions in Wildfly.

    umesh paliwal Newbie

      When my wilfly server start up , I am trying to delete a row in a table and create a new row using JPA (Entity Manager) from a pojo service. But the row is never getting deleted even when i do entitymanager.flush. I am getting the following exception in server log.

      Caused by: javax.ejb.EJBTransactionRolledbackException: Executing an update/delete query

      Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query

      Can you please help me. I am bit surprised because the same code works perfectly well in jboss 5.1.

       

      Complete Stack Trace.

       

      2014-09-17 16:33:07,636 ERROR [org.jboss.as.ejb3] (ServerService Thread Pool -- 90) javax.ejb.EJBTransactionRolledbackException: A different object with the same identifier value was already associated with the session : [com.osi.netexpert.apmconfig.service.ApmPropertiesEntity#APM]

      2014-09-17 16:33:07,636 ERROR [org.jboss.as.ejb3.invocation] (ServerService Thread Pool -- 90) JBAS014134: EJB Invocation failed on component ApmConfigServiceBean for method public abstract void com.osi.netexpert.apmconfig.service.ApmConfigService.saveApmProperties(com.osi.netexpert.system.NxSystemId,com.osi.netexpert.apmconfig.ApmProperties): javax.ejb.EJBTransactionRolledbackException: A different object with the same identifier value was already associated with the session : [com.osi.netexpert.apmconfig.service.ApmPropertiesEntity#APM]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.security.AuthorizationInterceptor.processInvocation(AuthorizationInterceptor.java:145) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)

        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:448)

        at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)

        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:185)

        at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73)

        at com.osi.netexpert.apmconfig.service.ApmConfigServiceLocal$$$view1.saveApmProperties(Unknown Source) [apmconfig-service.jar:${env.MAJOR_VERSION_NUMBER}.${env.MINOR_VERSION_NUMBER}]

        at com.osi.netexpert.apmconfig.impl.ApmConfigManagerImpl.saveApmProperties(ApmConfigManagerImpl.java:1978) [apmconfig.jar:${env.MAJOR_VERSION_NUMBER}.${env.MINOR_VERSION_NUMBER}]

        at com.osi.netexpert.deployment.kpimanagement.service.APMPropertiesPOJOService.setup(APMPropertiesPOJOService.java:146)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_60]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_60]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_60]

        at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_60]

        at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:114) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:103) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)

        at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

        at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.ejb.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:93) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:369) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)

        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160)

        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:133)

        at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:89)

        at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:122) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:137) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)

        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_60]

        at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_60]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]

        at org.jboss.threads.JBossThread.run(JBossThread.java:122)

      Caused by: javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [com.osi.netexpert.apmconfig.service.ApmPropertiesEntity#APM]

        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1735) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]

        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]

        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]

        at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1187) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]

        at org.jboss.as.jpa.container.AbstractEntityManager.persist(AbstractEntityManager.java:581) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]

        at com.osi.netexpert.apmconfig.service.ApmPropertiesDAO.createApmPropertiesEntity(ApmPropertiesDAO.java:65) [entity-jpa.jar:${env.MAJOR_VERSION_NUMBER}.${env.MINOR_VERSION_NUMBER}]

        at com.osi.netexpert.apmconfig.service.ApmConfigServiceBean.saveApmProperties(ApmConfigServiceBean.java:2932) [apmconfig-service.jar:${env.MAJOR_VERSION_NUMBER}.${env.MINOR_VERSION_NUMBER}]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_60]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_60]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_60]

        at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_60]

        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)

        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)

        at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

        at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:251) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]

        ... 90 more