Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Class org.hibernate.internal.SessionImpl does not implement the requested interface jakarta.persistence.EntityManager #952

Closed
@anil-subudhi

Description

@anil-subudhi

Hibernate dependencies:

grails-datastore-gorm-hibernate5-9.0.0-M2.jar
hibernate-commons-annotations-5.1.2.Final.jar
hibernate-core-5.6.15.Final.jar
hibernate-core-jakarta-5.6.15.Final.jar
hibernate-ehcache-5.6.15.Final.jar
hibernate-validator-8.0.2.Final.jar
hibernate5-9.0.0-M2.jar

Dependency tree of hibernate-echache

|    +--- org.hibernate:hibernate-ehcache:5.6.15.Final
|    |    +--- org.jboss.logging:jboss-logging:3.4.3.Final -> 3.6.1.Final
|    |    +--- org.hibernate:hibernate-core:5.6.15.Final

org.hibernate.internal.SessionImpl present in hibernate-core 5.6.15.Final doesn't implement jakarta.persistence.EntityManager
https://github.com/hibernate/hibernate-orm/blob/5.6/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java

Error:


Caused by: java.lang.IncompatibleClassChangeError: Class org.hibernate.internal.SessionImpl does not implement the requested interface jakarta.persistence.EntityManager
        at org.grails.orm.hibernate.HibernateGormStaticApi$_list_closure1.doCall(HibernateGormStaticApi.groovy:79)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Steps I checked,

excluded default hibernate-ehcache included explicitly and excluded hibernate-core

    implementation ("org.grails.plugins:hibernate5"){
      exclude module: "hibernate-ehcache"
    }
    implementation ("org.hibernate:hibernate-ehcache:5.6.15.Final"){
      exclude module: "hibernate-core"
    }

Now the hibernate dependencies

grails-datastore-gorm-hibernate5-9.0.0-M2.jar
hibernate-commons-annotations-5.1.2.Final.jar
hibernate-core-jakarta-5.6.15.Final.jar
hibernate-ehcache-5.6.15.Final.jar
hibernate-validator-8.0.2.Final.jar
hibernate5-9.0.0-M2.jar

Starting application without hibernate-core throws below error

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cache.ehcache.internal.SingletonEhcacheRegionFactory
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

SingletonEhcacheRegionFactory not present in hibernate-core-jakarta

Including hibernate-core higher version hibernate-core-6.6.4.Final.jar which has jakarta.persistence.EntityManager implementation throws below error

implementation group: 'org.hibernate.orm', name: 'hibernate-core', version: '6.6.4.Final'

https://github.com/hibernate/hibernate-orm/blob/6.6/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cache.ehcache.internal.SingletonEhcacheRegionFactory

It is only available upto hibernate-core-5.6

https://github.com/hibernate/hibernate-orm/blob/5.6/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/SingletonEhcacheRegionFactory.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions