hibernate/hibernate-orm · critical · HibernateException

Could not locate appropriate MutationExecutorService constru

Error message

Could not locate appropriate MutationExecutorService constructor : <className>

What it means

MutationExecutorServiceInitiator instantiates a custom MutationExecutorService configured via hibernate.jdbc.mutation.executor using Class.getConstructor().newInstance(). If the class has no public no-arg constructor, the NoSuchMethodException is wrapped in this HibernateException and SessionFactory boot fails.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorServiceInitiator.java:66

		}
		else if ( custom instanceof MutationExecutorService mutationExecutorService ) {
			return mutationExecutorService;
		}
		else {
			final Class<? extends MutationExecutorService> customImplClass;
			if ( custom instanceof Class ) {
				//noinspection unchecked
				customImplClass = (Class<? extends MutationExecutorService>) custom;
			}
			else {
				customImplClass = classLoaderService.classForName( custom.toString() );
			}

			try {
				return customImplClass.getConstructor().newInstance();
			}
			catch (NoSuchMethodException e) {
				throw new HibernateException(
						"Could not locate appropriate MutationExecutorService constructor : " + customImplClass.getName(),
						e );
			}
			catch (Exception e) {
				throw new HibernateException(
						"Unable to instantiate custom MutationExecutorService : " + customImplClass.getName(), e );
			}
		}
	}

	private static MutationExecutorService discover(ClassLoaderService classLoaderService) {
		final var discovered = classLoaderService.loadJavaServices( MutationExecutorService.class );
		final var iterator = discovered.iterator();
		if ( iterator.hasNext() ) {
			final var selected = iterator.next();
			if ( iterator.hasNext() ) {
				throw new HibernateException(
						"Multiple MutationExecutorService service registrations found via ServiceLoader; "

View on GitHub (pinned to fad1729dce)

Solutions

  1. Add a public no-argument constructor to the custom MutationExecutorService implementation
  2. Alternatively pass an already-constructed instance: put the instance itself (or make it available as such) into configurationValues under hibernateate.jdbc.mutation.executor — the initiator accepts a MutationExecutorService instance directly
  3. Ensure the class is public and top-level (or public static nested)

Example fix

// before
class MyExecutor implements MutationExecutorService {
    MyExecutor(Config cfg) { ... }
}

// after
public class MyExecutor implements MutationExecutorService {
    public MyExecutor() { this(defaultConfig()); }
    MyExecutor(Config cfg) { ... }
}
Defensive patterns

Strategy: validation

Validate before calling

// verify the custom executor is no-arg instantiable before boot
Class<?> c = Class.forName(props.getProperty("hibernate.jdbc.mutation.executor"));
if (c.getConstructor() == null) throw new IllegalStateException("needs public no-arg ctor");
// simpler: assert via reflection that newInstance() succeeds

Prevention

When it happens

Trigger: Setting hibernate.jdbc.mutation.executor=com.example.MyExecutor where MyExecutor lacks a public zero-argument constructor (only constructors with parameters, private constructor, or non-public class).

Common situations: Custom executor implementations that evolved to require constructor injection (a Spring bean, for example) while the initiator still needs a plain no-arg-instantiable class.

Related errors


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