0 Replies Latest reply on Aug 31, 2017 3:53 AM by Florin S

    "EntityManager is closed" error on MigrationManager

    Florin S Newbie

      Hello,

       

      We use a spring based jbpm integration something very similar to GitHub - mswiderski/spring-jbpm-app: jBPM spring application that shows how to build execution server using jBPM 6 and s…

      We have to be able to migrate instances from one process version to another and for this we are using

       

      MigrationReport report = new ProcessInstanceMigrationService().migrate(deploymentUnitV1.getIdentifier(), processInstanceId, deploymentUnitV2.getIdentifier(), "processID-V2");

       

      On MigrationManager.migrate(nodeMapping) method two KieSession objects are created, both containing different instances of type KieSpringJpaManager but sharing the same EntityManager instance. After the migration is done the two sessions are disposed. On disposing the second an "EntityManger is closed" error is arrised.

       

      Use use jBPM 6.5 commercial version, spring, hibernate, atomikos as TM, JTA enabled. Also we use KieSpringTransactionManagerFactory in order to pass by

      [RHBPMS-4657] [GSS](6.4.z) MigrationManager API throws NPE when used in Kie-Spring environment - JBoss Issue Tracker

       

      Do you have an ideea of how to overcome this?

      Thanks!

       

      [http-nio-8080-exec-2] 2017-08-31 10:52:27,070  WARN org.drools.persistence.SingleSessionCommandService.rollbackTransaction:408 - Could not commit session

      java.lang.IllegalStateException: EntityManager is closed

          at org.hibernate.jpa.internal.EntityManagerImpl.checkOpen(EntityManagerImpl.java:97) ~[hibernate-entitymanager-5.0.2.Final.jar:5.0.2.Final]

          at org.hibernate.jpa.internal.EntityManagerImpl.checkOpen(EntityManagerImpl.java:88) ~[hibernate-entitymanager-5.0.2.Final.jar:5.0.2.Final]

          at org.hibernate.jpa.spi.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1529) ~[hibernate-entitymanager-5.0.2.Final.jar:5.0.2.Final]

          at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.doJoinTransaction(ExtendedEntityManagerCreator.java:363) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]

          at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:330) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]

          at com.sun.proxy.$Proxy86.joinTransaction(Unknown Source) ~[na:na]

          at org.drools.persistence.jpa.JpaPersistenceContext.joinTransaction(JpaPersistenceContext.java:102) ~[drools-persistence-jpa-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.persistence.SingleSessionCommandService.destroy(SingleSessionCommandService.java:437) [drools-persistence-jpa-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:36) [drools-core-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:22) [drools-core-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.core.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:41) [drools-core-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.persistence.SingleSessionCommandService$TransactionInterceptor.execute(SingleSessionCommandService.java:563) [drools-persistence-jpa-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:397) [drools-persistence-jpa-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.destroy(CommandBasedStatefulKnowledgeSession.java:278) [drools-core-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.jbpm.runtime.manager.impl.migration.MigrationManager.migrate(MigrationManager.java:245) [jbpm-runtime-manager-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.jbpm.runtime.manager.impl.migration.MigrationManager.migrate(MigrationManager.java:102) [jbpm-runtime-manager-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]

          at org.jbpm.kie.services.impl.admin.ProcessInstanceMigrationServiceImpl.migrate(ProcessInstanceMigrationServiceImpl.java:46) [jbpm-kie-services-6.5.0.Final-redhat-15.jar:6.5.0.Final-redhat-15]