hibernate/hibernate-orm · error · HibernateException

Custom event-type name must be non-null.

Error message

Custom event-type name must be non-null.

What it means

HibernateException from EventEngine's ContributionManager.registerEventType validating the contribution contract: the name passed to EventEngineContributions.contributeEventType(String, Class) is null. Custom event types are keyed by name in the engine's map (used for later lookup and uniqueness), so a null name is rejected immediately during bootstrap contribution.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/EventEngine.java:110

		@Override
		@Nonnull
		public <T> EventType<T> findEventType(@Nonnull String name) {
			//noinspection unchecked
			return (EventType<T>) eventTypes.get( name );
		}

		@Override
		@Nonnull
		public <T> EventType<T> contributeEventType(@Nonnull String name, @Nonnull Class<T> listenerRole) {
			final var eventType = registerEventType( name, listenerRole );
			listenerRegistryBuilder.prepareListeners( eventType );
			return eventType;
		}

		@Nonnull
		private <T> EventType<T> registerEventType(@Nonnull String name, @Nonnull Class<T> listenerRole) {
			if ( name == null ) {
				throw new HibernateException( "Custom event-type name must be non-null." );
			}
			else if ( listenerRole == null ) {
				throw new HibernateException( "Custom event-type listener role must be non-null." );
			}
			// make sure it does not match an existing name...
			else if ( eventTypes.containsKey( name ) ) {
				final var existing = eventTypes.get( name );
				throw new HibernateException(
						"Custom event-type already registered: " + name + " => " + existing
				);
			}
			else {
				final EventType<T> eventType = EventType.create( name, listenerRole, eventTypes.size() );
				eventTypes.put( name, eventType );
				return eventType;
			}
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass a non-null, descriptive, namespaced name (e.g. 'com.acme.audit-event') from the contributor
  2. Default or validate configuration-derived names before contributing (Objects.requireNonNull(name, 'event type name required'))
  3. Add unit tests that bootstrap the contributor with all config states so null names fail in CI, not in production bootstrap

Example fix

// before
public void contribute(EventEngineContributions c) {
    c.contributeEventType(nameFromConfig, AuditListener.class); // nameFromConfig == null
}

// after
public void contribute(EventEngineContributions c) {
    String name = Objects.requireNonNullElse(nameFromConfig, "com.acme.audit");
    c.contributeEventType(name, AuditListener.class);
}
Defensive patterns

Strategy: validation

Validate before calling

public void contribute(EventEngineContributions c) {
    String name = Objects.requireNonNull(nameSource(), "event type name required");
    c.contributeEventType(name, MyListener.class);
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: An EventEngineContributor calling contributeEventType(null, listenerRole) — typically because the name was assembled from configuration/environment values or string helpers that returned null.

Common situations: Custom integrations deriving event-type names from annotations or config properties that may be absent; copy-paste contributor code with placeholder names; test contributors constructed with null arguments.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/a93037e7ee352c19. Report an issue: GitHub.