Hibernate Error – java.lang.NoClassDefFoundError: javax/transaction/Synchronization
Written on March 7, 2010 at 11:29 pm by
mkyong
This is caused by missing of the jta.jar library. It’s usually happened when you involve in the Hibernate’s transaction.
java.lang.NoClassDefFoundError: javax/transaction/Synchronization at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:213) at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:473) at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:497) at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:505) at com.mkyong.common.App.main(App.java:13) Caused by: java.lang.ClassNotFoundException: javax.transaction.Synchronization at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 5 more
Solution
The ‘jta.jar is not located at the Maven central repository, it just has jta’s pom file only.
You can download it in another two Maven’s repositories.
1. JBoss Maven repository
Add the addition JBoss Maven repository
<repositories> <repository> <id>JBoss repository</id> <url>http://repository.jboss.com/maven2/</url> </repository> </repositories>
and download the jta1.1.jar
<dependencies> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency> </dependencies>
2. Java net Maven repository
Add the addition Java net Maven repository
<repositories> <repository> <id>Java 2</id> <url>http://download.java.net/maven/2/</url> </repository> </repositories>
and download the jta1.0.1B.jar
<dependencies> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.0.1B</version> </dependency> </dependencies>
Oracle Magazine (Free)
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world\'s largest enterprise software company.
Publisher : Oracle Corporation


