Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/Synchronization
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.hibernateApp.packt.maven.hibernate.HibernateUtils.buildSessionFactory(HibernateUtils.java:26)
at net.hibernateApp.packt.maven.hibernate.HibernateUtils.<clinit>(HibernateUtils.java:15)
at net.hibernateApp.packt.maven.app.Main.save(Main.java:34)
at net.hibernateApp.packt.maven.app.Main.main(Main.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/Synchronization
at org.hibernate.impl.SessionFactoryImpl.buildCurrentSessionContext(SessionFactoryImpl.java:999)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:334)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at net.hibernateApp.packt.maven.hibernate.HibernateUtils.buildSessionFactory(HibernateUtils.java:20)
... 8 more
Caused by: java.lang.ClassNotFoundException: javax.transaction.Synchronization
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 13 more
Solution:
Add dependency to you pom file:
Maven central repository:
<dependencies> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency> </dependencies>
JBoss maven repository:
<repositories> <repository> <id>JBoss repository</id> <url>http://repository.jboss.com/maven2/</url> </repository> </repositories>
and add jar dependency:<dependencies> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency> </dependencies>
Brak komentarzy:
Prześlij komentarz