Vojtěch
Vojtěch

Reputation: 12416

Migration to Spring 6

I am trying to migrate to Spring 6 and I am getting stuck with following error:

Class org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider does not implement the requested interface jakarta.persistence.spi.PersistenceProvider
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 58 more

I checked and SpringHibernateJpaPersistenceProvider implements org.hibernate.jpa.HibernatePersistenceProvider which certainly implements jakarta.persistence.spi.PersistenceProvider.

I checked and there does not seem to be other versions on the classpath and also from the stacktrace you can see ~[spring-orm-6.0.2.jar:6.0.2] which means the current version should be correctly used. Where can I search for the error?

Upvotes: 1

Views: 570

Answers (1)

Vojtěch
Vojtěch

Reputation: 12416

This was caused by propagated dependency through c3p0:

implementation("org.hibernate:hibernate-core-jakarta:5.6.14.Final")
implementation("org.hibernate:hibernate-c3p0:5.6.14.Final") {
    // propagates unwanted hibernate-core module
    exclude(group = "org.hibernate", module = "hibernate-core")
}

Upvotes: 2

Related Questions