hibernate/hibernate-orm · error · HibernateException
EventType [
Error message
EventType [
What it means
HibernateException from EventEngine.ContributionManager.configureListeners: the EventType passed in is not among this engine's registered types (eventTypes.containsValue(eventType) is false). Standard and properly contributed custom types are all in the map, so this fires when the EventType instance comes from elsewhere — another SessionFactory's EventEngine or one constructed outside the contribution process — and the engine refuses to hand out a listener group for an unknown type object.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/EventEngine.java:143
return eventType;
}
}
@Override
@Nonnull
@SafeVarargs
public final <T> EventType<T> contributeEventType(@Nonnull String name, @Nonnull Class<T> listenerRole, @Nonnull T... defaultListeners) {
final var eventType = contributeEventType( name, listenerRole );
if ( defaultListeners != null ) {
listenerRegistryBuilder.getListenerGroup( eventType ).appendListeners( defaultListeners );
}
return eventType;
}
@Override
public <T> void configureListeners(@Nonnull EventType<T> eventType, @Nonnull Consumer<EventListenerGroup<T>> action) {
if ( !eventTypes.containsValue( eventType ) ) {
throw new HibernateException( "EventType [" + eventType + "] not registered" );
}
action.accept( listenerRegistryBuilder.getListenerGroup( eventType ) );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Resolve the EventType through the same engine you configure: engine.findRegisteredEventType(name), and if null, contribute it first via an EventEngineContributor
- Scope custom EventType references to a single SessionFactory instead of statics
- Guard with a null-check on findRegisteredEventType and fail with an explicit application-level message naming the missing event type
Example fix
// before
EventEngine otherEngine = firstFactory.getEventEngine();
EventType<AuditListener> t = otherEngine.findRegisteredEventType("com.acme.audit");
secondFactory.getEventEngine().configureListeners(t, g -> ...); // EventType not registered
// after
EventType<AuditListener> t2 = secondFactory.getEventEngine().findRegisteredEventType("com.acme.audit");
if (t2 != null) secondFactory.getEventEngine().configureListeners(t2, g -> g.appendListeners(new AuditListener())); Defensive patterns
Strategy: validation
Validate before calling
EventType<AuditListener> t = factory.getEventEngine().findRegisteredEventType("com.acme.audit");
if (t == null) {
throw new IllegalStateException("event type not registered on this factory — check contributors");
}
factory.getEventEngine().configureListeners(t, group -> group.appendListeners(new AuditListener())); Type guard
boolean knownToEngine(EventEngine engine, EventType<?> t) {
return engine.getRegisteredEventTypes().contains(t);
} Try / catch
null
Prevention
- Always resolve EventTypes from the engine instance you are configuring
- Never pass EventTypes between SessionFactories
- Register the EventEngineContributor with all factories that will use the type
When it happens
Trigger: Calling EventEngineContributions/engine.configureListeners(eventType, action) with an EventType resolved against a different factory (static cache across multi-factory tests or tenants), or with a hand-obtained EventType whose registration belongs to another bootstrap; code that mixes engine instances after refactoring.
Common situations: Integrations holding static EventType constants while the application builds several SessionFactories; test harnesses constructing minimal factories without the relevant contributor; helper APIs parameterized by EventType but invoked with the wrong factory's engine.
Related errors
- Unable to find listeners for type [
- Custom event-type name must be non-null.
- Custom event-type listener role must be non-null.
- Custom event-type already registered:
- The {storageEngine} storage engine is not supported
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/62e30d3dd857b15f.
Report an issue: GitHub.