When trying to use Hibernate and HikariCP on a Springboot Application, it fails to parse the JNDI name on any Hibernate call.
Here is the project where I am facing this Issue here
The entire code for the SQL handling is within a library
I have been trying to fix this Issue for the past month or so, sadly I was not able to.
It seems like it has something to do with an internal change within hibernate or springboot, since reverting to an older version of Hibernate it worked for a while, but when upgrading Springboot it did not work anymore.
Exception:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Error parsing JNDI name [com.zaxxer.hikari.HikariDataSource]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:276) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.model.relational.Database.<init>(Database.java:45) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:191) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:169) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:128) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:451) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:102) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:910) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at de.presti.ree6.sql.SQLSession.buildSessionFactory(SQLSession.java:231) ~[Ree6-SQL-2.1.5.jar:2.1.5]
at de.presti.ree6.sql.SQLSession.getSessionFactory(SQLSession.java:314) ~[Ree6-SQL-2.1.5.jar:2.1.5]
at de.presti.ree6.sql.SQLWorker.getEntityList(SQLWorker.java:2342) ~[Ree6-SQL-2.1.5.jar:2.1.5]
at de.presti.ree6.sql.SQLWorker.getEntityList(SQLWorker.java:2311) ~[Ree6-SQL-2.1.5.jar:2.1.5]
at de.presti.ree6.backend.utils.data.DatabaseStorageBackend.loadCredentials(DatabaseStorageBackend.java:23) ~[classes/:na]
at com.github.philippheuer.credentialmanager.CredentialManager.load(CredentialManager.java:188) ~[credentialmanager-0.2.2.jar:na]
at com.github.philippheuer.credentialmanager.CredentialManager.<init>(CredentialManager.java:64) ~[credentialmanager-0.2.2.jar:na]
at com.github.philippheuer.credentialmanager.CredentialManagerBuilder.build(CredentialManagerBuilder.java:48) ~[credentialmanager-0.2.2.jar:na]
at de.presti.ree6.backend.Server.load(Server.java:178) ~[classes/:na]
at de.presti.ree6.backend.WebinterfaceApplication.main(WebinterfaceApplication.java:31) ~[classes/:na]
Caused by: org.hibernate.engine.jndi.JndiException: Error parsing JNDI name [com.zaxxer.hikari.HikariDataSource]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:134) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:95) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:98) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:135) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:391) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:259) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:105) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:129) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
... 20 common frames omitted
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or in an application resource file: java.naming.factory.initial
at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:704) ~[na:na]
at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305) ~[na:na]
at java.naming/javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:342) ~[na:na]
at java.naming/javax.naming.InitialContext.getNameParser(InitialContext.java:497) ~[na:na]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:128) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
... 31 common frames omitted