Hibernate gradle plugin with jpms error

I have a jpms project and using hibernate gradle plugin but i got this error

Unable to enhance class : module-info
Cannot invoke "net.bytebuddy.description.type.TypeDefinition.asErasure()" because "managedCtSuperclass" is null

This is my gradle plugin settings

hibernate {
  enhancement {

The error message you’re encountering indicates that there’s an issue with class enhancement during the build process. This can happen if Hibernate tries to enhance the module-info.class file, which is the module descriptor introduced in Java 9.

To resolve this issue, you can exclude the module-info.class file from the class enhancement process. You can achieve this by configuring the Hibernate Gradle plugin to exclude certain classes from enhancement.

Here’s how you can modify your Gradle configuration to exclude the module-info.class file from enhancement:

hibernate {
enhancement {
enableLazyInitialization = true
enableDirtyTracking = true
enableAssociationManagement = true
enableExtendedEnhancement = true

    // Exclude module-info.class from enhancement
    enableContextualClassNode = false


By setting enableContextualClassNode to false, you’re instructing the Hibernate plugin not to enhance the module-info.class file.

After making this change, try rebuilding your project and see if the error persists. If the error persists, there might be other issues with your project configuration or dependencies that need to be addressed. In that case, further investigation would be necessary.

  • Certainly! Here are the key points for resolving the issue with class enhancement in Hibernate Gradle plugin:

  • Error Description: Encounter error message indicating inability to enhance module-info.class.

  • Cause: Hibernate attempts to enhance module-info.class, which is the module descriptor introduced in Java 9.

  • Solution Approach:Exclude module-info.class: Configure Hibernate Gradle plugin to exclude module-info.class from enhancement.

  • Gradle Configuration:Use hibernate.enhancement.enableContextualClassNode = false to exclude module-info.class. KrogerFeedback

  • Verification: Rebuild the project to ensure the error has been resolved.

  • Further Investigation: If the error persists, investigate other potential issues in project configuration or dependencies.

Implementing these points should help resolve the issue with class enhancement in your Hibernate Gradle project.

I am using hibernate gradle plugin version 6.4.4.Final and there no configuration naming enableContextualClassNode in enhancement