Main Tutorials

java.lang.ClassNotFoundException: javax.transaction.TransactionManager

Problem

In JPA or Hibernate development, it hits the following error message :


Caused by: java.lang.ClassNotFoundException: javax.transaction.TransactionManager
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)
… 23 more

Solution

The javax.transaction.TransactionManager is a class inside the J2EE SDK library “javaee.jar“, you are missing this jar file in your project classpath.

1. J2EE SDK

You can always get the javaee.jar from http://java.sun.com/javaee/. Download and install the SDK in your computer, the javaee.jar can be found in the “\J2EE_SDK_FOLDER\lib” folder. For example,


C:\Sun\SDK\lib\javaee.jar

Get the javaee.jar file and include it in your project classpath.

2. Java.Net Repository

Alternatively, you can get the “javaee.jar” from the java.net Maven


  <repositories>
  	<repository>
  		<id>Java.Net</id>
  		<url>http://download.java.net/maven/2/</url>
  	</repository>
  </repositories>
 
  <dependencies>
    <!-- Javaee API -->
	<dependency>
    	<groupId>javax</groupId>
    	<artifactId>javaee-api</artifactId>
    	<version>6.0</version>
	</dependency>
  </dependencies>
The downloaded java.net javaee.jar is not contains any method bodies, see this “how to get javaee.jar from Maven” article for detail.

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
7 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Geneva Balmir
11 years ago

I simply needed to appreciate you yet again. I do not know the things that I might have done without the entire points provided by you on that situation. It had become the traumatic setting in my circumstances, nevertheless encountering the very skilled avenue you handled it made me to jump with delight. I’m grateful for this advice and in addition sincerely hope you really know what an amazing job your are undertaking teaching men and women by way of your website. I know that you haven’t encountered any of us.

anitha
4 years ago

Caused by: java.lang.ClassNotFoundException: weblogic.transaction.TxHelper getting this error working with wildfly 16

Jose
10 years ago

Thanks!!!!!!!!!!!!!!!!

Mohd
11 years ago

Hi Mkyong,

I have deployed my Application in Tomcat.5.x Server and facing one issue with j2ee.jar .

When I am adding J2ee.jar in apache-tomcat-6.0.26\lib folder Its working fine.

When I am adding J2ee.jar WEB-INF\lib folder then I am getting below exception

exception
javax.servlet.ServletException: Servlet execution threw an exception

root cause
java.lang.NoClassDefFoundError: javax/transaction/TransactionManager

Kindly advice me.

Regards,
Mohammed

Quân Chùa
10 years ago
Reply to  mkyong

oh after many times i googled and tried alot but finally your comment help me solve my problem…thank you very much…

Chandu
13 years ago

Thx dude…hope that helps