Error Exception in thread "JavaFX Application Thread" java.lang.ExceptionInInitializerError .

HibernateUtil class:

 import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtil { private static final SessionFactory ourSessionFactory; static { try { Configuration configuration = new Configuration(); configuration.configure(); ourSessionFactory = configuration.buildSessionFactory(); } catch (Throwable ex) { throw new ExceptionInInitializerError(ex); } } public static Session getSession() throws HibernateException { return ourSessionFactory.openSession(); } } 

HibernateUtil.cfg.xml :

 <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hbm2ddl.auto">create</property> <property name="connection.url">jdbc:postgresql://localhost:5432/personal</property> <property name="connection.username">postgres</property> <property name="connection.password"></property> <property name="connection.driver_class">org.postgresql.Driver</property> <mapping class="Entity.UsersEntity"/> </session-factory> </hibernate-configuration> 

Please tell me what the problem is. postgres is established, communication is established.

Added dependencies:

  <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.3.0.CR2</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.2</version> </dependency> <dependency> <groupId>org.jboss.logging</groupId> <artifactId>jboss-logging</artifactId> <version>3.3.2.Final</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.8.0-beta2</version> </dependency> </dependencies> 

Mistake :

  Exception in thread "JavaFX Application Thread" java.lang.ExceptionInInitializerError at Util.HibernateUtil.<clinit>(HibernateUtil.java:18) at DAO.UserDAO.list(UserDAO.java:43) at Controllers.ControllerRegistration.dublicateEmail(ControllerRegistration.java:259) at Controllers.ControllerRegistration.lambda$emailTF$4(ControllerRegistration.java:172) at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:360) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80) at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72) at javafx.graphics/javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:8134) at javafx.graphics/javafx.scene.Scene$12.invalidated(Scene.java:2183) at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112) at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147) at javafx.graphics/javafx.scene.Scene$KeyHandler.setFocusOwner(Scene.java:4043) at javafx.graphics/javafx.scene.Scene$KeyHandler.requestFocus(Scene.java:4090) at javafx.graphics/javafx.scene.Scene$KeyHandler.access$1700(Scene.java:4029) at javafx.graphics/javafx.scene.Scene.requestFocus(Scene.java:2150) at javafx.graphics/javafx.scene.Node.requestFocus(Node.java:8295) at javafx.controls/com.sun.javafx.scene.control.behavior.TextFieldBehavior.mousePressed(TextFieldBehavior.java:253) at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274) at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.base/javafx.event.Event.fireEvent(Event.java:198) at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3876) at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604) at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874) at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433) at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556) at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175) at java.base/java.lang.Thread.run(Thread.java:844) Caused by: org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE hibernate.cfg.xml. Message: null at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:133) at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65) at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:165) at org.hibernate.cfg.Configuration.configure(Configuration.java:258) at org.hibernate.cfg.Configuration.configure(Configuration.java:244) at Util.HibernateUtil.<clinit>(HibernateUtil.java:14) ... 46 more Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath. - with linked exception: [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory] at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278) at javax.xml.bind.ContextFinder.find(ContextFinder.java:421) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662) at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:122) ... 52 more Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122) at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276) ... 56 more 
  • Add the full text of the error to the code. - Sergey Gornostaev
  • Updated the question. - Fedia Cholak
  • It looks like you are using version 9 or 10 of Java. So? - Sergey Gornostaev
  • That's right, version 9 - Fedia Cholak
  • one
    Hibernate uses JAXB, and in Java 9 it was taken from the standard library to the java.xml.bind module . - Sergey Gornostaev

1 answer 1

If you read the entire trace carefully, you will be able to notice that the exception for the ExceptionInInitializerError was the NoSuchMethodError exception. The exception NoSuchMethodError versions of the libraries are incompatible. Judging by javax.persistence.Table.indexes()[Ljavax/persistence/Index; incompatibility in JPA version.

  • Removed some jaxb dependencies, and the error changed. Now ConfigurationException. I updated the question. - Fedia Cholak
  • And now your program lacks JAXB again. I do not endlessly engage with you in choosing the right combination of dependencies. You must understand what you use, how, and what are the relationships between them. - Sergey Gornostaev
  • So help, how to solve this problem? - Fedia Cholak
  • Sergey, will you help me? And it seems that in the answer they wrote that they know, but they did not write the solutions. - Fedia Cholak 5:03 pm
  • There is no magic recipe that helps in all cases. It is necessary to analyze the relationships used in your project dependencies and select the necessary combination of libraries of compatible versions. I am not ready to do this. Moreover, such assistance is already beyond the limits of the Stackoverflow format. - Sergey Gornostaev pm