From Hibernate 6.2 it is mandatory enabled CDI extensions to work with Spring Container, this is included in Spring 3.1 in the class HibernateJpaVendorAdapter (spring-orm). The problem it is in the class DefaultRevisionInfoGenerator (hibernate-envers) when the method resolveRevisionListenerBean it is executed due to the condition {{Helper.allowExtensionsInCdi( serviceRegistry )}}should be negated.
private ManagedBean<? extends RevisionListener> resolveRevisionListenerBean(
Class<? extends RevisionListener> listenerClass,
ServiceRegistry serviceRegistry) {
if ( !listenerClass.equals( RevisionListener.class ) ) {
if ( Helper.allowExtensionsInCdi( serviceRegistry ) ) {
return new ProvidedInstanceManagedBeanImpl<>(
FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( listenerClass )
);
}
return serviceRegistry.getService( ManagedBeanRegistry.class ).getBean( listenerClass );
}
return null;
}
To reproduce you can use my demo to test it, mgvinuesa/hibernate-envers-spring: A demo of how to wire Spring Framework 5.1+ to inject beans into Hibernate Envers RevisionListener (github.com) If you change the spring boot version to 3.0, everything works properly, but when it is updated to 3.1, the RevisionListener does not work properly. |