{"record":{"id":"6c8071bd208bde7f","repo":"hibernate/hibernate-orm","slug":"bytecode-enhancement-failed-for-class-originalcl","errorCode":null,"errorMessage":"Bytecode enhancement failed for class '{originalClass}' (it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package - in this case, the class should be opened and exported to Hibernate ORM)","messagePattern":"Bytecode enhancement failed for class '(.+?)' \\(it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package - in this case, the class should be opened and exported to Hibernate ORM\\)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java","lineNumber":318,"sourceCode":"\n\t\tpublic FieldAccessor.PropertyConfigurable getInterceptorFieldAccessor() {\n\t\t\treturn interceptorFieldAccessor;\n\t\t}\n\n\t\tpublic DynamicType.Builder<?> appendIgnoreAlsoAtEnd(DynamicType.Builder<?> builder) {\n\t\t\tfor ( var elementMatcher : toFullyIgnore ) {\n\t\t\t\tbuilder = builder.ignoreAlso( elementMatcher );\n\t\t\t}\n\t\t\treturn builder;\n\t\t}\n\t}\n\n\tprivate static ClassLoadingStrategy<ClassLoader> resolveClassLoadingStrategy(Class<?> originalClass) {\n\t\ttry {\n\t\t\treturn ClassLoadingStrategy.UsingLookup.of( MethodHandles.privateLookupIn( originalClass, LOOKUP ) );\n\t\t}\n\t\tcatch (Throwable e) {\n\t\t\tthrow new HibernateException( \"Bytecode enhancement failed for class '\" + originalClass.getName()\n\t\t\t\t\t+ \"' (it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package\"\n\t\t\t\t\t+ \" - in this case, the class should be opened and exported to Hibernate ORM)\", e );\n\t\t}\n\t}\n\n\tprivate static class FixedNamingStrategy extends NamingStrategy.AbstractBase {\n\t\tprivate final String className;\n\n\t\tpublic FixedNamingStrategy(String className) {\n\t\t\tthis.className = className;\n\t\t}\n\n\t\t@Override\n\t\tprotected String name(TypeDescription typeDescription) {\n\t\t\treturn className;\n\t\t}\n\t}\n}","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java#L300-L336","documentation":"Error \"Bytecode enhancement failed for class '{originalClass}' (it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package - in this case, the class should be opened and exported to Hibernate ORM)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Bytecode enhancement, proxy creation, or lazy interception is applied to an incompatible class or configuration.","commonSituations":"Build-time enhancement with module-system restrictions, mismatched Hibernate versions between build and runtime, or hibernate.bytecode.provider=none with a model that needs proxies.","solutions":["Open and export the entity package to Hibernate ORM (module-info: 'opens com.acme.model to org.hibernate.orm.core') or move enhancement to build time."],"exampleFix":"Open and export the entity package to Hibernate ORM (module-info: 'opens com.acme.model to org.hibernate.orm.core') or move enhancement to build time.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}