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 the Author

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

Comments

Leave a Reply

avatar
newest oldest most voted
Jose
Guest
Jose

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

Mohd
Guest
Mohd

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

Geneva Balmir
Guest
Geneva Balmir

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.

Chandu
Guest
Chandu

Thx dude…hope that helps