java.lang.ClassNotFoundException: org.hibernate.service.jta.platform.spi.JtaPlatform

Spring 3.2.x + Hibernate 4.3.x integration, hits JtaPlatform ClassNotFoundException, search the project classpath, find out that JtaPlatform is at different package?

hibernate-core.4.3.5.Final.jar

org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform

Error message shows org.hibernate.service.jta.platform.spi.JtaPlatform


Caused by: java.lang.NoClassDefFoundError: org/hibernate/service/jta/platform/spi/JtaPlatform
	at org.springframework.orm.hibernate4.SpringSessionContext.<init>(SpringSessionContext.java:56) 
	~[spring-orm-3.2.8.RELEASE.jar:3.2.8.RELEASE]
	... 40 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.service.jta.platform.spi.JtaPlatform
//...
pom.xml
	
  <!-- Hibernate ORM -->
  <dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-core</artifactId>
	<version>4.3.5.Final</version>
  </dependency>

  <!-- Spring 3 dependencies -->
  <dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-core</artifactId>
	<version>3.2.8.RELEASE</version>
  </dependency>

  <dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-orm</artifactId>
	<version>3.2.8.RELEASE</version>
  </dependency>

Solution

Since Hibernate 4.3.x, the JtaPlatform class is refactored to a new package. To fix it, downgrade Hibernate to 4.2.x or older, or upgrade the Spring framework.

Tested on my development environment, here are the version that works :

  1. Spring 3.2.8.RELEASE
  2. Hibernate 4.2.11.Final
pom.xml
	
  <dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-core</artifactId>
	<version>4.2.11.Final</version>
  </dependency>

  <dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-core</artifactId>
	<version>3.2.8.RELEASE</version>
  </dependency>

About the Author

author image
mkyong
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

avatar
3 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
Dhirendra HamalamineEdgar de Graaff Recent comment authors
newest oldest most voted
Dhirendra Hamal
Guest
Dhirendra Hamal

This is a very resourceful tutorial… thanks alot..

amine
Guest
amine

thank man

Edgar de Graaff
Guest
Edgar de Graaff

Thanks a lot!