Uploaded image for project: 'Hibernate ORM'
  1. HHH-8818

Hibernate 4.3.0.Final can no longer find JNDI DataSource that <=4.2.x and 4.3.0.Beta4 could find

    Details

      Description

      I have attached a simple, one-Servlet project that duplicates this issue. You can also see the issue reported in this Stack Overflow question (I didn't post that) and this forum post (posted by the same person it appears).

      The attached project worked fine with Hibernate 4.2.x and through Hibernate 4.3.0.Beta4. I have not tested with 4.3.0.Beta5-4.3.0.CR1, but 4.3.0.CR2 and 4.3.0.Final result in the following error on Tomcat 7 and 8:

      javax.persistence.PersistenceException: Unable to build entity manager factory
      	org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:81)
      	org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
      	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
      	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
      	com.wrox.site.EntityServlet.init(EntityServlet.java:49)
      	javax.servlet.GenericServlet.init(GenericServlet.java:160)
      	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
      	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
      	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
      	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
      	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:646)
      	org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
      	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1576)
      	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
      	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	java.lang.Thread.run(Thread.java:744)
      
      root cause
      org.hibernate.engine.jndi.JndiException: Unable to lookup JNDI name [java:comp/env/jdbc/EntityMappings]
      	org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:117)
      	org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:115)
      	org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
      	org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
      	org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
      	org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
      	org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
      	org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
      	org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
      	org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
      	org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:399)
      	org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
      	org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:73)
      	org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
      	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
      	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
      	com.wrox.site.EntityServlet.init(EntityServlet.java:49)
      	javax.servlet.GenericServlet.init(GenericServlet.java:160)
      	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
      	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
      	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
      	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
      	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:646)
      	org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
      	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1576)
      	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
      	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	java.lang.Thread.run(Thread.java:744)
      
      root cause
      javax.naming.NameNotFoundException: Name [java:comp/env/jdbc/EntityMappings] is not bound in this Context. Unable to find [java:comp].
      	org.apache.naming.NamingContext.lookup(NamingContext.java:820)
      	org.apache.naming.NamingContext.lookup(NamingContext.java:153)
      	javax.naming.InitialContext.lookup(InitialContext.java:421)
      	org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:114)
      	org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:115)
      	org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
      	org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
      	org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
      	org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
      	org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
      	org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
      	org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
      	org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
      	org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
      	org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:399)
      	org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
      	org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:73)
      	org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
      	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
      	javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
      	com.wrox.site.EntityServlet.init(EntityServlet.java:49)
      	javax.servlet.GenericServlet.init(GenericServlet.java:160)
      	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
      	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
      	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
      	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
      	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:646)
      	org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
      	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1576)
      	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
      	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	java.lang.Thread.run(Thread.java:744)

      It would appear that, starting somewhere in 4.3.0.Beta5, 4.3.0.CR1, or 4.3.0.CR2, Hibernate stopped being able to resolve JNDI DataSource resources in Tomcat. This makes Hibernate 4.3.0.Final completely unusable, meaning this is a blocking issue. Until this is fixed, I will have to downgrade to 4.3.0.Beta4.

      The reporter of the Stack Overflow question and forum post believes he has found the likely culprit: a change in the JndiServiceImpl#locate method.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                12 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: