Saturday, February 17, 2018

How to configure Maven projects to use a specific JDK version?

Hello friends, today the scope of our discussion would be related to configuring Maven project and  cross-compilation feature of Java. Precisely we would talk about below points:
  • the right way of configuring Maven projects to use specific JDK version
  • important pointers related to Java compiler & it's cross compilation feature 
  • common misconception while configuring the Maven compiler plugin 

Friday, February 2, 2018

java.lang.NoClassDefFoundError: javax/transaction/TransactionManager

Recently while trying to migrate one of the application from JDK6 to JDK7 & Spring 3.x to Spring 4.x, I have got Spring  BeanCreationException along with nested exception related to javax TransactionManger while deploying the application in Tomcat 7.

Before sharing the logs, providing the tech stack:
- Maven based application
- Spring 4.x [4.3.0.RELEASE from 3.1.0.RELEASE]
- Tomcat 7.0.83
- JDK 7 [1.7.0_05]

Error Logs:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'xyz' defined in class path resource [xyz/xyz.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: 
javax/transaction/TransactionManager 

Solution:

Don't be confused with the BeanCreationException, the issue is happening due to missing jta jar.
Add the below Maven dependency and issue will be resolved:
<dependency>
    <groupId>javax.transaction</groupId>
    <artifactId>jta</artifactId>
    <version>1.1</version>
</dependency>