2

Well, I'm working in a JPA project with Eclipse. I use: Hibernate, JavaFX and jOOQ and I'll use Jasper. On Eclipse the project is running normally, but when I to export a runnable jar and try execute the jar is thrown the exception.

Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(Unknown Source)
        at com.sun.javafx.application.LauncherImpl$$Lambda$48/1851691492.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
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 javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
        at br.com.olk.srv.dao.OlkDAO.<init>(OlkDAO.java:24)
        at br.com.olk.cli.controller.Main.<init>(Main.java:19)
        at br.com.olk.cli.view.LoginApp.start(LoginApp.java:24)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
        at com.sun.javafx.application.LauncherImpl$$Lambda$51/1604076978.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
        at com.sun.javafx.application.PlatformImpl$$Lambda$45/1108411398.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
        at com.sun.javafx.application.PlatformImpl$$Lambda$47/854215995.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
        at com.sun.javafx.application.PlatformImpl$$Lambda$46/584634336.run(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
        at com.sun.glass.ui.win.WinApplication$$Lambda$37/1267032364.run(Unknown Source)
        ... 1 more
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
        at org.hibernate.cache.internal.NoCachingRegionFactory.buildNaturalIdRegion(NoCachingRegionFactory.java:89)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:381)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
        at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
        ... 20 more
Exception running application br.com.olk.cli.view.LoginApp

I think that can be because the runnable file isn't found inside the jar file. How I can make that the runnable jar file find the persistence.xml file?

In short, how I run the runnable jar file as I do in Eclipse? (Finding the persistence.xml file)

1 Answers1

1

Your problem is not that the persistence.xml missing, but because of this:

Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.

I have talked about this error in here: https://stackoverflow.com/a/29109009/3116666

Community
  • 1
  • 1
uaiHebert
  • 1,882
  • 11
  • 21
  • 1
    Thanks uaiHebert! I resolved this using the post that you sent to me. How I use the Hibernate 4.x, I changed "net.sf.ehcache.hibernate.EhCacheRegionFactory" to "org.hibernate.cache.ehcache.EhCacheRegionFactory", then now is running. Thanks so much. – Jimmy Tinelli Mar 19 '15 at 02:43