actframework / act-eclipselink

Provide JPA support via EclipseLink
Apache License 2.0
1 stars 1 forks source link

EntityManagerFactoryProvider.emSetupImpls needs to be reset upon hotreload #12

Open greenlaw110 opened 5 years ago

greenlaw110 commented 5 years ago

Otherwise, we will get the following error logs when external data source (e.g. HikariCP) is used:

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.1.v20171221-bd47e8f): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
Error Code: 0
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:846)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:216)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:324)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:348)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:311)
    at act.db.jpa.JPAService.createEntityManager(JPAService.java:273)
    at act.db.jpa.JPAContext$Info.<init>(JPAContext.java:46)
    at act.db.jpa.JPAContext.ensureInfo(JPAContext.java:119)
    at act.db.jpa.JPAContext.emWithTx(JPAContext.java:174)
    at act.db.jpa.JPADao.em(JPADao.java:339)
    at act.db.jpa.JPADao.q(JPADao.java:236)
    at act.db.jpa.JPADao.q(JPADao.java:219)
    at act.db.jpa.JPADao.deleteAll(JPADao.java:205)
    at act.db.jpa.JPADao.drop(JPADao.java:210)
    at act.test.Test.clearFixtures(Test.java:196)
    at act.test.TestMethodAccess.invoke(Unknown Source)
    at act.handler.builtin.controller.impl.ReflectedHandlerInvoker.invoke(ReflectedHandlerInvoker.java:1042)
    at act.handler.builtin.controller.impl.ReflectedHandlerInvoker.invoke(ReflectedHandlerInvoker.java:1028)
    at act.handler.builtin.controller.impl.ReflectedHandlerInvoker.handle(ReflectedHandlerInvoker.java:663)
    at act.handler.builtin.controller.ControllerAction.handle(ControllerAction.java:49)
    at act.handler.builtin.controller.RequestHandlerProxy._handle(RequestHandlerProxy.java:558)
    at act.handler.builtin.controller.RequestHandlerProxy.handle(RequestHandlerProxy.java:210)
    at act.app.ActionContext.proceedWithHandler(ActionContext.java:1326)
    at act.route.Router$ContextualHandler.handle(Router.java:1714)
    at act.xio.NetworkHandler$3.run(NetworkHandler.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)