Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zubaidullo opened this issue Oct 12, 2020 · 4 comments

Comments

@zubaidullo
Copy link

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
Copy link
Author

Version information:

<ninja.version>6.6.1</ninja.version>
<jetty.version>9.4.18.v20190429</jetty.version>

@zubaidullo
Copy link
Author

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

@thibaultmeyer
Copy link
Contributor

thibaultmeyer commented Dec 28, 2021

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
Copy link
Contributor

danielsawan commented Sep 10, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants