My application using Spring Boot 3.3.2 connects to multiple instances of the same DB structure, as each DB is owned by differente clients. Said dabatases have names in spanish, but our application is developed completely in english. I tried to create a AttributeConverter so I can transform one of the fields, that represents a status as ACTIVE or INACTIVE instead of ACTIVO and INACTIVO.
My converter looks like this:
import com.arkdia.seus.service.master.db.multi.enums.StatusEnum;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter(autoApply = true)
public class StatusEnumConverter implements AttributeConverter<StatusEnum, String> {
@Override
public String convertToDatabaseColumn(StatusEnum attribute) {
return switch (attribute) {
case ACTIVO -> "ACTIVO";
case INACTIVO -> "INACTIVO";
};
}
@Override
public StatusEnum convertToEntityAttribute(String dbData) {
return switch (dbData) {
case "ACTIVO" -> StatusEnum.ACTIVO;
case "INACTIVO" -> StatusEnum.INACTIVO;
default -> throw new IllegalArgumentException("Unknown status: " + dbData);
};
}
}
Everything was working fine until I added that converter, that’s when I started to get this error:
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.orm.hibernate5.LocalSessionFactoryBuilder.scanPackages(LocalSessionFactoryBuilder.java:365)
The following method did not exist:
'void org.springframework.orm.hibernate5.LocalSessionFactoryBuilder.addAttributeConverter(java.lang.Class)'
The calling method's class, org.springframework.orm.hibernate5.LocalSessionFactoryBuilder, was loaded from the following location:
jar:file:/.m2/repository/org/springframework/spring-orm/6.1.11/spring-orm-6.1.11.jar!/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.class
The called method's class, org.springframework.orm.hibernate5.LocalSessionFactoryBuilder, is available from the following locations:
jar:file:.m2/repository/org/springframework/spring-orm/6.1.11/spring-orm-6.1.11.jar!/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.class
The called method's class hierarchy was loaded from the following locations:
org.springframework.orm.hibernate5.LocalSessionFactoryBuilder: file:/.m2/repository/org/springframework/spring-orm/6.1.11/spring-orm-6.1.11.jar
org.hibernate.cfg.Configuration: file:/.m2/repository/org/hibernate/orm/hibernate-core/6.5.2.Final/hibernate-core-6.5.2.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.orm.hibernate5.LocalSessionFactoryBuilder
This are my dependencies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.arkdia.seus.service.commons</groupId>
<artifactId>seus-commons</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.google.maps</groupId>
<artifactId>google-maps-routing</artifactId>
<version>1.21.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Any idea of what the problem could be?