ebrukaya
ebrukaya

Reputation: 1

After upgraded Hibernate-Jakarta version, application doesn't work

I upgraded hibernate-core-jakarta version. I get this error when trying to run the project. The project includes; Java17, spring boot 2.7.x java.lang.NoClassDefFoundError: org/springframework/aot/hint/TypeHint$Builder

error logs

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core-jakarta</artifactId>
  <version>5.6.14.Final</version>
</dependency>
<dependency>
  <groupId>jakarta.persistence</groupId>
  <artifactId>jakarta.persistence-api</artifactId>
  <version>3.1.0</version>
</dependency>
<dependency>
  <groupId>jakarta.transaction</groupId>
  <artifactId>jakarta.transaction-api</artifactId>
  <version>2.0.1</version>
</dependency>
<dependency>
  <groupId>jakarta.validation</groupId>
  <artifactId>jakarta.validation-api</artifactId>
  <version>3.0.2</version>
</dependency>
<dependency>
  <groupId>org.eclipse.angus</groupId>
  <artifactId>jakarta.mail</artifactId>
  <version>1.0.0</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-web</artifactId>
  <version>6.0.0</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context-support</artifactId>
  <version>6.0.3</version>
</dependency>
<dependency>
  <groupId>jakarta.activation</groupId>
  <artifactId>jakarta.activation-api</artifactId>
  <version>2.0.1</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>6.0.0</version>
</dependency>

Upvotes: 0

Views: 2080

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 108965

With Spring Boot 2.7, you should use the normal hibernate-core dependency, not hibernate-core-jakarta. You should also let Spring Boot manage the versions of your dependencies, not specify them yourself.

You seem to have added multiple dependencies using the jakarta.* package namespace, which do not work with Spring Boot 2.7, you would need to upgrade to Spring Boot 3.0 if you want to use Jakarta EE 9 libraries (and again, then you should still let Spring Boot manage your versions instead of specifying them yourself).

The same goes for Spring. Spring Boot 2.7 uses Spring 5.3, it cannot use Spring 6. This is likely the immediate cause of the "java.lang.NoClassDefFoundError: org/springframework/aot/hint/TypeHint$Builder".

TL;DR, stop managing your versions like this, and let Spring Boot manage them for you.

If you want to use Jakarta EE 9+ (using the jakarta.* package namespace) and Spring 6 dependencies, you have to upgrade to Spring Boot 3, not upgrade individual dependencies yourself.

Upvotes: 3

Related Questions