I am upgrading an app from an older version of Spring (4) to Spring 6 and Spring Boot from 2.* to 3.2.5. It compiles, but I cannot run it due to the following stack trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: UUID
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-6.1.6.jar!/:6.1.6]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) ~[spring-beans-6.1.6.jar!/:6.1.6]
// Additional stack trace
Caused by: java.lang.NoSuchFieldError: UUID
at org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory.registerJpaGenerators(StandardIdentifierGeneratorFactory.java:111) ~[hibernate-core-6.4.4.Final.jar!/:6.4.4]
// Additional stack trace
Below is my pom.xml file content:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.spring</groupId>
<artifactId>bioMedical</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>bioMedical</name>
<description>Demo project for Spring Boot</description>
<packaging>war</packaging>
<properties>
<java.version>17</java.version>
</properties>
<!-- Dependencies -->
</project>
The only class where UUID is used is in the RegisterController. Here’s the relevant part of that class:
package com.spring.bioMedical.Controller;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nulabinc.zxcvbn.Strength;
import com.nulabinc.zxcvbn.Zxcvbn;
import com.spring.bioMedical.entity.User;
import com.spring.bioMedical.service.EmailService;
import com.spring.bioMedical.service.UserService;
@Controller
public class RegisterController {
// Methods with @RequestMapping annotations
}
Can anyone help identify why this error occurs and how to fix it?