org.hibernate.bytecode.enhance.EnhancementException: Unable to enhance persistent attribute [hbm.test.Address:country]

Hibernate JIRA | Johnny Macchione | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    When trying to enhance classes annotated with @Entity or @Embeddable at build-time, hibernate-enhance-maven-plugin logs an EnhancementException "Unable to enhance persistent attribute [<class>:<attribute>]" for some association attributes (annotated with @ManyToOne, @OneToOne, ...). I've noticed that the error occurs only for classes containing attributes referencing classes that haven't been processed by the plugin yet. See the attached test project (hbm-enhance-test) to reproduce this issue. Here is an extract of the Maven log showing the issue: [INFO] Started enhance plugin..... [INFO] Processing Composite class file [hbm.test.Address]. [ERROR] Unable to enhance class [hbm.test.Address] org.hibernate.bytecode.enhance.EnhancementException: Unable to enhance persistent attribute [hbm.test.Address:country] at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:367) ... (skipped) Caused by: javassist.NotFoundException: hbm.test.Country at javassist.ClassPool.get(ClassPool.java:450) at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:592) at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:542) at javassist.CtField.getType(CtField.java:371) at org.hibernate.bytecode.enhance.spi.Enhancer.resolveAttributeTypeDescriptor(Enhancer.java:1103) at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:358) ... 28 more [INFO] Processing Entity class file [hbm.test.Country]. [INFO] Processing Entity class file [hbm.test.Director]. ... Note that the build doesn't fail, even though those classes are not enhanced. On Windows, version 4.3.8 of the plugin is also affected by issue HHH-9581, which will interfer while testing this issue.

    Hibernate JIRA | 2 years ago | Johnny Macchione
    org.hibernate.bytecode.enhance.EnhancementException: Unable to enhance persistent attribute [hbm.test.Address:country]
  2. 0

    When trying to enhance classes annotated with @Entity or @Embeddable at build-time, hibernate-enhance-maven-plugin logs an EnhancementException "Unable to enhance persistent attribute [<class>:<attribute>]" for some association attributes (annotated with @ManyToOne, @OneToOne, ...). I've noticed that the error occurs only for classes containing attributes referencing classes that haven't been processed by the plugin yet. See the attached test project (hbm-enhance-test) to reproduce this issue. Here is an extract of the Maven log showing the issue: [INFO] Started enhance plugin..... [INFO] Processing Composite class file [hbm.test.Address]. [ERROR] Unable to enhance class [hbm.test.Address] org.hibernate.bytecode.enhance.EnhancementException: Unable to enhance persistent attribute [hbm.test.Address:country] at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:367) ... (skipped) Caused by: javassist.NotFoundException: hbm.test.Country at javassist.ClassPool.get(ClassPool.java:450) at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:592) at javassist.bytecode.Descriptor.toCtClass(Descriptor.java:542) at javassist.CtField.getType(CtField.java:371) at org.hibernate.bytecode.enhance.spi.Enhancer.resolveAttributeTypeDescriptor(Enhancer.java:1103) at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:358) ... 28 more [INFO] Processing Entity class file [hbm.test.Country]. [INFO] Processing Entity class file [hbm.test.Director]. ... Note that the build doesn't fail, even though those classes are not enhanced. On Windows, version 4.3.8 of the plugin is also affected by issue HHH-9581, which will interfer while testing this issue.

    Hibernate JIRA | 2 years ago | Johnny Macchione
    org.hibernate.bytecode.enhance.EnhancementException: Unable to enhance persistent attribute [hbm.test.Address:country]

    Root Cause Analysis

    1. org.hibernate.bytecode.enhance.EnhancementException

      Unable to enhance persistent attribute [hbm.test.Address:country]

      at org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute()
    2. Hibernate
      Enhancer.enhancePersistentAttribute
      1. org.hibernate.bytecode.enhance.spi.Enhancer.enhancePersistentAttribute(Enhancer.java:367)
      1 frame