javax.persistence.PersistenceException: Unable to build EntityManagerFactory

Hibernate JIRA | Artem V. Navrotskiy | 5 years ago
  1. 0

    If you run GWT application from JetBrains Idea in Dev Mode, GWT builds custom ClassLoader. When Hibernate creates of any object by it's name (Dialect for example), if class available for SystemClassLoader it's will be created by SystemClassLoader. Not by a current ClassLoader. This is due to the fact that the class ClassLoaderServiceImpl$1 uses SystemClassLoader as parent ClassLoader. Stacktrace: javax.persistence.PersistenceException: Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) at ru.buzzsoft.common.HibernateHelper.createEntityManagerFactory(HibernateHelper.java:180) at ru.buzzsoft.delivery.PersistentFactory.getEntityPersonalFactory(PersistentFactory.java:21) at ru.buzzsoft.delivery.server.api.impl.ContextImpl.<init>(ContextImpl.java:126) at ru.buzzsoft.delivery.server.api.impl.ContextImpl.<init>(ContextImpl.java:89) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at java.lang.Class.newInstance0(Class.java:372) at java.lang.Class.newInstance(Class.java:325) at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153) at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:253) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:222) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672) at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509) at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068) at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811) at com.google.gwt.dev.DevMode.main(DevMode.java:311) Caused by: org.hibernate.HibernateException: Could not instantiate dialect class at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:82) at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ... 32 more Caused by: java.lang.ClassCastException: org.hibernate.dialect.H2Dialect cannot be cast to org.hibernate.dialect.Dialect at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73) ... 43 more

    Hibernate JIRA | 5 years ago | Artem V. Navrotskiy
    javax.persistence.PersistenceException: Unable to build EntityManagerFactory
  2. 0

    If you run GWT application from JetBrains Idea in Dev Mode, GWT builds custom ClassLoader. When Hibernate creates of any object by it's name (Dialect for example), if class available for SystemClassLoader it's will be created by SystemClassLoader. Not by a current ClassLoader. This is due to the fact that the class ClassLoaderServiceImpl$1 uses SystemClassLoader as parent ClassLoader. Stacktrace: javax.persistence.PersistenceException: Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) at ru.buzzsoft.common.HibernateHelper.createEntityManagerFactory(HibernateHelper.java:180) at ru.buzzsoft.delivery.PersistentFactory.getEntityPersonalFactory(PersistentFactory.java:21) at ru.buzzsoft.delivery.server.api.impl.ContextImpl.<init>(ContextImpl.java:126) at ru.buzzsoft.delivery.server.api.impl.ContextImpl.<init>(ContextImpl.java:89) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at java.lang.Class.newInstance0(Class.java:372) at java.lang.Class.newInstance(Class.java:325) at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153) at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:253) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:222) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672) at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509) at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068) at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811) at com.google.gwt.dev.DevMode.main(DevMode.java:311) Caused by: org.hibernate.HibernateException: Could not instantiate dialect class at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:82) at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ... 32 more Caused by: java.lang.ClassCastException: org.hibernate.dialect.H2Dialect cannot be cast to org.hibernate.dialect.Dialect at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73) ... 43 more

    Hibernate JIRA | 5 years ago | Artem V. Navrotskiy
    javax.persistence.PersistenceException: Unable to build EntityManagerFactory
  3. 0

    Hazelcast-hibernate on apache karaf

    Google Groups | 2 years ago | Ahmedin Yimer
    javax.persistence.PersistenceException: [PersistenceUnit: nletsPU] Unable to build EntityManagerFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error creating bean with name 'entityManagerFactory' defined in class path resource

    Stack Overflow | 1 year ago | fatCop
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory
  6. 0

    ModeShape - Inconsistent or invalid Node Types followed by NullPointerException during server start-up (MS-SQL)

    https://bugzilla.redhat.com/bugzilla/ | 3 years ago | Steve Johnson
    javax.persistence.PersistenceException: [PersistenceUnit: gadget-core] Unable to build EntityManagerFactory

  1. davidvanlaatum 5 times, last 4 weeks ago
  2. Tahir 4 times, last 2 months ago
  3. Kawada 22 times, last 7 months ago
11 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassCastException

    org.hibernate.dialect.H2Dialect cannot be cast to org.hibernate.dialect.Dialect

    at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
    2. org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
    3. org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146)
    4. org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    5. org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    6. org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    7. org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
    8. org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)
    9. org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)
    10. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)
    10 frames
  3. Hibernate EJB
    Ejb3Configuration.buildEntityManagerFactory
    1. org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88)
    2. org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
    3. org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
    3 frames
  4. ru.buzzsoft.common
    HibernateHelper.createEntityManagerFactory
    1. ru.buzzsoft.common.HibernateHelper.createEntityManagerFactory(HibernateHelper.java:180)
    1 frame
  5. ru.buzzsoft.delivery
    ContextImpl.<init>
    1. ru.buzzsoft.delivery.PersistentFactory.getEntityPersonalFactory(PersistentFactory.java:21)
    2. ru.buzzsoft.delivery.server.api.impl.ContextImpl.<init>(ContextImpl.java:126)
    3. ru.buzzsoft.delivery.server.api.impl.ContextImpl.<init>(ContextImpl.java:89)
    3 frames
  6. Java RT
    Class.newInstance
    1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    4. java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    5. java.lang.Class.newInstance0(Class.java:372)
    6. java.lang.Class.newInstance(Class.java:325)
    6 frames
  7. Jetty Server
    ServletHolder.doStart
    1. org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    2. org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:253)
    2 frames
  8. Jetty Util
    AbstractLifeCycle.start
    1. org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    1 frame
  9. Jetty Server
    WebAppContext.doStart
    1. org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616)
    2. org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    3. org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
    4. org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
    5. org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
    5 frames
  10. GWT dev
    JettyLauncher$WebAppContextWithReload.doStart
    1. com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468)
    1 frame
  11. Jetty Util
    AbstractLifeCycle.start
    1. org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    1 frame
  12. Jetty Server
    RequestLogHandler.doStart
    1. org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    2. org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
    2 frames
  13. Jetty Util
    AbstractLifeCycle.start
    1. org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    1 frame
  14. Jetty Server
    Server.doStart
    1. org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    2. org.mortbay.jetty.Server.doStart(Server.java:222)
    2 frames
  15. Jetty Util
    AbstractLifeCycle.start
    1. org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    1 frame
  16. GWT dev
    DevMode.main
    1. com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
    2. com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
    3. com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)
    4. com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
    5. com.google.gwt.dev.DevMode.main(DevMode.java:311)
    5 frames