Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caused by: java.lang.NoClassDefFoundError: Ljavax/transaction/TransactionManager;

I read many posts about the error javax/transaction/TransactionManager, but none of those solutions fix my problem.

First thing to say is that I get that error when I deploy my web-application (made with Spring MVC and Hibernate) on the server. On my computer, with Eclipse and Tomcat 7 everything works.

Second thing to say is that on that server I have another web-application that's running under tomcat /root folder (this is a simple java application, that DOESN'T use neither Spring mvc nor Hibernate). The new application that i'm trying to deploy is running under another folder called /prova.

These are all the libraries of my application enter image description here

Plus, according to what I read on some posts, I added to my lib folder:

1) jta-3.1.2.2.jar

2) hibernate3.3.1-jta-1.1.jar

3) javax.transaction.jar

In my xml file I have this bean that defines the transaction manager

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
     <property name="sessionFactory" ref="sessionFactory" />
</bean>

Something strange is that in the server log the exact error is

Caused by: java.lang.NoClassDefFoundError: Ljavax/transaction/TransactionManager;

There's a L before javax/transaction/TransactionManager

Any idea?

Thank you

like image 866
MDP Avatar asked Mar 05 '26 08:03

MDP


2 Answers

This worked for me

<dependency>
    <groupId>javax.transaction</groupId>
    <artifactId>javax.transaction-api</artifactId>
    <version>1.3</version>
</dependency>
like image 129
Prateek Mehta Avatar answered Mar 06 '26 22:03

Prateek Mehta


Don't worry with the "L", it just defines that the following is an object. You can find other letters :

BaseType
B     byte (signed byte)
C     char (Unicode character)
D     double (double-precision floating-point value)
F     float (single-precision floating-point value)
I     int (integer)
J     long (long integer)
L<classname>;     reference (an instance of class <classname>)
S     short (signed short)
Z     boolean (true or false)
[     reference (one array dimension )

To come back to your problem, did you define your transaction manager whith something close to this :

<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory">
</bean>

HibernateTransactionManager is an implementation of javax.transaction.TransactionManager

like image 24
Snorky35 Avatar answered Mar 06 '26 21:03

Snorky35



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!