0

I have encountered an issue while using Hibernate Search.

The versions I am using are as follows:

Java21
Spring Boot 3.2.7 
Hibernate 6.4.9.Final
hibernate-search-backend-elasticsearch:7.1.0.Final 
VM option: -javaagent:/aspectjweaver-1.9.22.jar -javaagent:/spring-instrument-6.1.10.jar

Here's the example code that's causing the problem:

@Indexed
@Entity
abstract class Parent {
    @GenericField(projectable = Projectable.YES, sortable = Sortable.YES, searchable = Searchable.YES)
    private LocalDateTime createdDate;
}

@Entity
class Child extends Parent {

}

When I start the application, I run into this error:

Caused by: java.lang.NoSuchMethodException: com.project.Child.$$_hibernate_read_createdDate()
  at java.base/java.lang.Class.getMethod(Class.java:2395)
  at org.hibernate.search.mapper.orm.model.impl.HibernateOrmBootstrapIntrospector.getBytecodeEnhancerReaderMethod(HibernateOrmBootstrapIntrospector.java:187)
  ... 80 common frames omitted

Upon debugging, I found that the exception is thrown in the following logic, and I suspect a conflict occurs when using the VM option -javaagent:/spring-instrument-6.1.10.jar. If I remove -javaagent:/spring-instrument-6.1.10.jar from the VM options, the method returns null as expected:

private static Method getBytecodeEnhancerReaderScheme(Class<?> holderClass, Field field) {
    if (!PersistentAttributeInterceptable.class.isAssignableFrom(holderClass)) {
        return null;
    } else {
        try {
            return holderClass.getMethod("$$_hibernate_read_" + field.getName());
        } catch (NoSuchMethodException e) {
            throw new AssertionFailure("Read method for enhanced field " + field + " is unexpectedly missing.", e);
        }
    }
}

This problem did not occur with earlier versions but has begun after attempting to upgrade. Please, I need a resolution to this issue.

For your information, it appears that the PersistentAttributeInterceptable interface is being set as reflectionData on the child class entity.

5
  • I don't think you should have the parent class annotated with @Entity it should be annotated with @MappedSupperClass instead. docs.jboss.org/hibernate/orm/5.4/userguide/html_single/… Commented Jul 18 at 23:04
  • By the way if this is an issue with hibernate you should post this problem on their GitHub (or issue tracking system). SO is likely not the correct place for it. Commented Jul 18 at 23:07
  • Thank you for your response. I have also registered the issue on Hibernate's JIRA for further assistance. hibernate.atlassian.net/browse/HSEARCH-5205
    – qwer
    Commented Jul 19 at 0:41
  • Same question asked there too... discourse.hibernate.org/t/…
    – yrodiere
    Commented Jul 19 at 6:40
  • 1
    BTW, in my opinion it is always preferable to directly use aspectjweaver as a Java agent to cover all classloaders instead of using spring-instrument, which does nothing else but attach aspectjweaver during runtime, only way later than when used directly.
    – kriegaex
    Commented Jul 20 at 9:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.