Search code examples
hibernatehibernate-reactive

Hibernate Reactive NoClassDefFound for "org.hibernate.engine.spi.ComparableExecutable" class after migrating to 2.0.0.Final


I recently upgraded the hibernate-reactive to the newest version and struggling to fix the issue with NoClassDedfFound, I tried to follow the example from the github docs, here is the list of my dependencies used for rds persistence

 // rds reactive db
    implementation 'org.hibernate.reactive:hibernate-reactive-core:2.0.0.Final'
    implementation "org.hibernate:hibernate-core:6.2.4.Final"
    implementation 'com.ongres.scram:client:2.1'
    implementation 'org.hibernate.validator:hibernate-validator:7.0.2.Final'
    implementation 'io.smallrye.reactive:mutiny-reactor:2.2.0'
    implementation 'io.vertx:vertx-pg-client:4.4.2'
    implementation 'org.postgresql:postgresql'
    implementation 'org.glassfish:jakarta.el:4.0.2'

The exception is happening when I am trying to create the EntityManagerFactory

    @Bean
    public EntityManagerFactory entityManagerFactory(@Autowired(required = false) SpringLiquibase liquibase) {
        return createEntityManagerFactory("postgres", hibernateProperties());
    }

    public Map<String, String> hibernateProperties() {
        var connectionUrl = rdsProperties.getConnectionUrl();
        System.out.println(connectionUrl);
        var isNotProd = !activeProfile.equals("prod");
        return Map.of(
                "jakarta.persistence.jdbc.url", connectionUrl,
                "jakarta.persistence.jdbc.user", rdsProperties.getUsername(),
                "jakarta.persistence.jdbc.password", rdsProperties.getPassword(),
                "jakarta.persistence.schema-generation.database.action", rdsProperties.getDdlAuto(),

                "hibernate.show_sql", "false", //String.valueOf(isNotProd),
                "hibernate.default_schema", rdsProperties.getSchema()
        );
    }

Solution

  • You need to check you are using the correct Hibernate ORM version in your project.

    ComparableExecutable is a new interface in Hibernate ORM 6.2.4.Final.

    I can see that there is an error in your configuration, the correct GAV for Hibernate ORM should be:

        implementation 'org.hibernate.orm:hibernate-core:6.2.4.Final'
    

    See the group: org.hibernate.orm

    But if your are including org.hibernate.reactive:hibernate-reactive-core:2.0.0.Final, there's no need to also include Hibernate ORM. It's already a transitive dependency.