hibernate/hibernate-orm · error · HibernateException
event name to resolve cannot be null
Error message
event name to resolve cannot be null
What it means
HibernateException from EventType.resolveEventTypeByName(null): the helper that maps event-name strings (the names used in hibernate.cfg.xml <event type=...> blocks and programmatic listener configuration) to EventType instances requires a non-null name and fails fast otherwise. It exists purely to give a clearer error than an NPE deep in map lookup.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/EventType.java:121
@Nonnull
public static <T> EventType<T> create(@Nonnull String name, @Nonnull Class<T> listenerRole, int ordinal) {
return new EventType<>( name, listenerRole, ordinal, false );
}
/**
* Find an {@link EventType} by its name
*
* @param eventName The name
*
* @return The {@link EventType} instance.
*
* @throws HibernateException If eventName is null, or if eventName does not correlate to any known event type.
*/
@Nonnull
public static EventType<?> resolveEventTypeByName(@Nonnull final String eventName) {
if ( eventName == null ) {
throw new HibernateException( "event name to resolve cannot be null" );
}
final EventType<?> eventType = STANDARD_TYPE_BY_NAME_MAP.get( eventName );
if ( eventType == null ) {
throw new HibernateException( "Unable to locate proper event type for event name [" + eventName + "]" );
}
return eventType;
}
/**
* Get a collection of all the standard {@link EventType} instances.
*/
@Nonnull
public static Collection<EventType<?>> values() {
return STANDARD_TYPE_BY_NAME_MAP.values();
}
/**
* Used from {@link EventEngine} to "prime" the registered event-type map.View on GitHub (pinned to fad1729dce)
Solutions
- Validate the name before resolving: Objects.requireNonNull(name) at the config boundary with a message pointing at the offending entry
- Fix the configuration source — supply the missing type attribute / filter out blank entries before parsing into listener registration
- When the type is known statically, use EventType constants directly instead of name resolution
Example fix
// before
String evtName = config.get("event.type"); // missing in config -> null
EventType<?> t = EventType.resolveEventTypeByName(evtName); // event name to resolve cannot be null
// after
String evtName = Objects.requireNonNull(config.get("event.type"), "'event.type' must be set");
EventType<?> t = EventType.resolveEventTypeByName(evtName); Defensive patterns
Strategy: validation
Validate before calling
String name = Objects.requireNonNull(config.get("event.type"), "'event.type' missing in configuration");
EventType<?> t = EventType.resolveEventTypeByName(name); Type guard
null
Try / catch
null
Prevention
- Validate parsed configuration keys before feeding them to Hibernate APIs
- Use schema-validated config binding (Spring Boot @ConfigurationProperties) that rejects missing attributes
- Prefer EventType constants over name strings where possible
When it happens
Trigger: Passing a null event name — e.g. configuration parsing code that reads an event type attribute which is missing from the XML/properties and forwards the null into resolveEventTypeByName; generic bootstrap helpers accepting a nullable name parameter.
Common situations: Hand-edited hibernate.cfg.xml/hbm files with a malformed <event> element lacking its type attribute; custom configuration loaders that iterate configured event names and hit an unset entry; copy-paste config code where the name variable was never assigned.
Related errors
- The specified class cannot be null
- Unable to locate proper event type for event name [
- Bean instance cannot be null
- VALIDATE is not valid SchemaManagementTool action for script
- The {storageEngine} storage engine is not supported
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/51ffbc89ccea8b37.
Report an issue: GitHub.