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

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]