ninjaframework / ninja

Ninja is a full stack web framework for Java. Rock solid, fast and super productive.
http://www.ninjaframework.org
Apache License 2.0
1.91k stars 518 forks source link

Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory #687

Open zubaidullo opened 4 years ago

zubaidullo commented 4 years ago

Hi Ninja Community,

I'm testing steps here: http://www.ninjaframework.org/documentation/working_with_relational_dbs/jpa.html Created a new project from documentation and tried to run jar file as a standalone app, the same guidance from doc. java -Dninja.port=9000 -jar MY-APPLICATION.jar

Getting this error, also from the document I see information if it's related to the error or not don't know.

Please be aware that since Ninja 6.4.3, alongside with Jetty 9.4.12, the dependency allowing Jetty servlets annotations (that should not be useful for your Ninja Framework project) have been excluded from the stack. This was caused by an incompatibility between the version of the java bytecode handler ASM used by this module (6.2) and the java bytecode handler javassist used by Hibernate.

16:47:30.783 [NinjaJetty] INFO org.hibernate.Version - HHH000412: Hibernate Core {4.3.8.Final} 16:47:30.783 [NinjaJetty] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found 16:47:30.784 [NinjaJetty] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist 16:47:31.673 [NinjaJetty] ERROR ninja.standalone.NinjaJetty - Unable to start NinjaJetty ninja.lifecycle.FailedStartException: javax.persistence.PersistenceException: Unable to build entity manager factory at ninja.lifecycle.LifecycleRegister.invokeTarget(LifecycleRegister.java:103) at ninja.lifecycle.LifecycleRegister.start(LifecycleRegister.java:55) at ninja.lifecycle.LifecycleServiceImpl.start(LifecycleServiceImpl.java:84) at ninja.NinjaDefault.onFrameworkStart(NinjaDefault.java:156) at ninja.Bootstrap.boot(Bootstrap.java:119) at ninja.servlet.NinjaServletListener.createNinjaBootstrap(NinjaServletListener.java:152) at ninja.servlet.NinjaServletListener.getInjector(NinjaServletListener.java:123) at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:45) at ninja.servlet.NinjaServletListener.contextInitialized(NinjaServletListener.java:75) at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:957) at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:553) at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:922) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:365) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:852) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:278) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:167) at org.eclipse.jetty.server.Server.start(Server.java:418) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:382) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at ninja.standalone.NinjaJetty.doStart(NinjaJetty.java:167) at ninja.standalone.AbstractConsole.start(AbstractConsole.java:77) at ninja.standalone.AbstractStandalone.run(AbstractStandalone.java:113) at ninja.standalone.NinjaJetty.main(NinjaJetty.java:70) Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:83) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at com.google.inject.persist.jpa.JpaPersistService.start(JpaPersistService.java:110) at ninja.jpa.JpaInitializer.start(JpaInitializer.java:52) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at ninja.lifecycle.LifecycleRegister.invokeTarget(LifecycleRegister.java:96) ... 25 common frames omitted Caused by: org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile at org.hibernate.jpa.boot.scan.spi.ClassFileArchiveEntryHandler.toClassFile(ClassFileArchiveEntryHandler.java:88) at org.hibernate.jpa.boot.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:65) at org.hibernate.jpa.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:176) at org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:72) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:725) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:221) at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:51) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:182) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:131) at org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:93) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:88) at org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:101) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:69) ... 34 common frames omitted

zubaidullo commented 4 years ago

Version information:

<ninja.version>6.6.1</ninja.version>
<jetty.version>9.4.18.v20190429</jetty.version>
zubaidullo commented 4 years ago

[SOLVED] updating maven-shade-plugin from 2.2 -> 3.2.x solved the above issue.

thibaultmeyer commented 2 years ago

Same issue here with OpenJDK8 and Ninja 6.8.1. I have to upgrade Hibernate dependencies to 5.6.3.Final too. Now the single shaded jar working well.

It may be time to update these outdated dependencies.

DEPENDENCY CURRENT VERSION LATEST_VERSION
hibernate-entitymanager 4.3.8.Final (Jan, 2015) 5.6.3.Final (Dec, 2021)
hibernate-c3p0 4.3.8.Final (Jan, 2015) 5.6.3.Final (Dec, 2021)
maven-shade-plugin 3.2.1 (Nov, 2018) 3.2.4 (Jun, 2020)

@jjlauer @raphaelbauer

danielsawan commented 2 years ago

I totally agree why are we still using such an old version of hibernate ? It is not even compatible with mysql 8 server with is the default mysql server version of most linux servers.

We can't use org.hibernate.dialect.MySQL8Dialect in this version