So I have a project with modules, one of these modules is database, in the database module I have the setup for hibernate, my program allows certain modules to be reloaded so I close the hibernate sessionFactory when I do reload it. However when I create my SessionFactory again We recieve an error saying that H2 is locked by another process. At first I thought this might be the connection pool (C3P0) not closing, so I switched to HikariCP and have the same issue. If we listen to the H2 error it says a connection is already open, but this is towards the old Database because of how H2 works I'm unable to check what that connection is. Why do I think this is a Hibernate issue?: sessionFactory.close() should close all connections, it's somehow not? I am unable to find any fix as of right now.
My Repository (link to Hibernate setup): https://github.com/Articdive/Metropoles/blob/master/src/main/java/de/articdive/metropoles/database/HibernateDatabase.java
StackTraces: [13:50:46] [Server thread/WARN]: org.hibernate.HibernateException: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Database may be already in use: "Locked by another process: C:/Users/Lukas/Desktop/BuildTools/Test Server/1.13/plugins/Metropoles/data/metropoles.lock.db". Possible solutions: close all other connection(s); use the server mode [90020-197] [13:50:46] [Server thread/WARN]: at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:63) [13:50:46] [Server thread/WARN]: at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:100) [13:50:46] [Server thread/WARN]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246) [13:50:46] [Server thread/WARN]: at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [13:50:46] [Server thread/WARN]: at de.articdive.metropoles.database.HibernateDatabase.loadSettings(HibernateDatabase.java:115) [13:50:46] [Server thread/WARN]: at de.articdive.metropoles.database.HibernateDatabase.<init>(HibernateDatabase.java:78) [13:50:46] [Server thread/WARN]: Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Database may be already in use: "Locked by another process: C:/Users/Lukas/Desktop/BuildTools/Test Server/1.13/plugins/Metropoles/data/metropoles.lock.db". Possible solutions: close all other connection(s); use the server mode [90020-197] [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:512) [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:105) [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:71) [13:50:46] [Server thread/WARN]: at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:59) [13:50:46] [Server thread/WARN]: ... 22 more [13:50:46] [Server thread/WARN]: Caused by: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process: C:/Users/Lukas/Desktop/BuildTools/Test Server/1.13/plugins/Metropoles/data/metropoles.lock.db". Possible solutions: close all other connection(s); use the server mode [90020-197] [13:50:46] [Server thread/WARN]: at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) [13:50:46] [Server thread/WARN]: at org.h2.message.DbException.get(DbException.java:179) [13:50:46] [Server thread/WARN]: at org.h2.message.DbException.get(DbException.java:155) [13:50:46] [Server thread/WARN]: at org.h2.store.FileLock.getExceptionAlreadyInUse(FileLock.java:433) [13:50:46] [Server thread/WARN]: at org.h2.store.FileLock.lockFile(FileLock.java:325) [13:50:46] [Server thread/WARN]: at org.h2.store.FileLock.lock(FileLock.java:108) [13:50:46] [Server thread/WARN]: at org.h2.engine.Database.open(Database.java:674) [13:50:46] [Server thread/WARN]: at org.h2.engine.Database.openDatabase(Database.java:286) [13:50:46] [Server thread/WARN]: at org.h2.engine.Database.<init>(Database.java:280) [13:50:46] [Server thread/WARN]: at org.h2.engine.Engine.openSession(Engine.java:66) [13:50:46] [Server thread/WARN]: at org.h2.engine.Engine.openSession(Engine.java:179) [13:50:46] [Server thread/WARN]: at org.h2.engine.Engine.createSessionAndValidate(Engine.java:157) [13:50:46] [Server thread/WARN]: at org.h2.engine.Engine.createSession(Engine.java:140) [13:50:46] [Server thread/WARN]: at org.h2.engine.Engine.createSession(Engine.java:28) [13:50:46] [Server thread/WARN]: at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:351) [13:50:46] [Server thread/WARN]: at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124) [13:50:46] [Server thread/WARN]: at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:103) [13:50:46] [Server thread/WARN]: at org.h2.Driver.connect(Driver.java:69) [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:95) [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:101) [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:341) [13:50:46] [Server thread/WARN]: at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:506) |
|