Object belongs to another EntityManager - ERROR

#1

Hi,

From time to time we are getting following error in our project when trying to insert/update a record in database

[ObjectDB 2.4.6_13] javax.persistence.RollbackException
10:29:14,880 ERROR [stderr] (http--10.23.3.98-8081-5) Failed to commit transaction: Object 'pbdmodel.impl.OrgJedinicaImpl#8' belongs to another EntityManager (error 613)
10:29:14,887 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.jpa.EMImpl.commit(EMImpl.java:290)
10:29:14,895 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.pbd.evidention.dao.EvidencijaZaposlenihDAO.updateEvidencijaZaposlenih(EvidencijaZaposlenihDAO.java:408)
10:29:14,905 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.pbd.evidention.view.edit.EvidencijaZaposlenihNewEditView.updateEvidencijaZaposlenih(EvidencijaZaposlenihNewEditView.java:2257)
10:29:14,914 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.pbd.evidention.view.edit.EvidencijaZaposlenihNewEditView$3.menuSelected(EvidencijaZaposlenihNewEditView.java:268)
10:29:14,931 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.ui.MenuBar.changeVariables(MenuBar.java:186)
10:29:14,934 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:403)
10:29:14,944 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:228)
10:29:14,955 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
10:29:14,960 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.PushHandler$2.run(PushHandler.java:158)
10:29:14,968 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:275)
10:29:14,972 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.PushHandler.onRequest(PushHandler.java:295)
10:29:14,976 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:259)
10:29:14,980 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
10:29:14,984 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:101)
10:29:14,989 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1448)
10:29:14,993 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.communication.PushRequestHandler.handleRequest(PushRequestHandler.java:109)
10:29:14,998 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
10:29:15,002 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
10:29:15,006 ERROR [stderr] (http--10.23.3.98-8081-5)  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
10:29:15,009 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
10:29:15,014 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
10:29:15,019 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
10:29:15,023 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
10:29:15,027 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
10:29:15,032 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
10:29:15,036 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
10:29:15,041 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
10:29:15,045 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
10:29:15,049 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
10:29:15,053 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
10:29:15,059 ERROR [stderr] (http--10.23.3.98-8081-5)  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
10:29:15,063 ERROR [stderr] (http--10.23.3.98-8081-5)  at java.lang.Thread.run(Thread.java:662)
10:29:15,066 ERROR [stderr] (http--10.23.3.98-8081-5) Caused by: javax.persistence.PersistenceException: com.objectdb.o.UserException: Object 'pbdmodel.impl.OrgJedinicaImpl#8' belongs to another EntityManager
10:29:15,072 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o._PersistenceException.b(_PersistenceException.java:47)
10:29:15,076 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.JPE.g(JPE.java:142)
10:29:15,079 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.JPE.g(JPE.java:78)
10:29:15,082 ERROR [stderr] (http--10.23.3.98-8081-5)  ... 34 more
10:29:15,084 ERROR [stderr] (http--10.23.3.98-8081-5) Caused by: com.objectdb.o.UserException: Object 'pbdmodel.impl.OrgJedinicaImpl#8' belongs to another EntityManager
10:29:15,089 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.MSG.d(MSG.java:61)
10:29:15,092 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.OBC.aD(OBC.java:610)
10:29:15,095 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.OBC.aC(OBC.java:595)
10:29:15,098 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.OBM.bz(OBM.java:315)
10:29:15,101 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.EPR.Uo(EPR.java:81)
10:29:15,104 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.CLT.visitRefs(CLT.java:160)
10:29:15,107 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.TVS.j(TVS.java:169)
10:29:15,110 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.TVS.cascade(TVS.java:156)
10:29:15,113 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.STA.Q(STA.java:476)
10:29:15,116 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.STM.E(STM.java:407)
10:29:15,118 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.OBM.bK(OBM.java:903)
10:29:15,121 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.jdo.PMImpl.bK(PMImpl.java:2187)
10:29:15,125 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.OBM.bJ(OBM.java:819)
10:29:15,127 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.o.OBM.bH(OBM.java:734)
10:29:15,130 ERROR [stderr] (http--10.23.3.98-8081-5)  at com.objectdb.jpa.EMImpl.commit(EMImpl.java:287)
10:29:15,134 ERROR [stderr] (http--10.23.3.98-8081-5)  ... 31 more

We are not sure what is happening here, because the error is not throw on every transaction commit.

#2

This exception is thrown only when mixing entity objects of different entity managers (which is forbidden, since every EntityManager manages its own space of managed objects, and a managed object of one EntityManager should not be used with another EntityManager).

See also this discussion in a former forum thread.

ObjectDB Support

Reply