{"record":{"id":"62ca074d1ea6b042","repo":"hibernate/hibernate-orm","slug":"could-not-locate-appropriate-mutationexecutorservi","errorCode":null,"errorMessage":"Could not locate appropriate MutationExecutorService constructor : <className>","messagePattern":"Could not locate appropriate MutationExecutorService constructor : <className>","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"critical","filePath":"hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorServiceInitiator.java","lineNumber":66,"sourceCode":"\t\t}\n\t\telse if ( custom instanceof MutationExecutorService mutationExecutorService ) {\n\t\t\treturn mutationExecutorService;\n\t\t}\n\t\telse {\n\t\t\tfinal Class<? extends MutationExecutorService> customImplClass;\n\t\t\tif ( custom instanceof Class ) {\n\t\t\t\t//noinspection unchecked\n\t\t\t\tcustomImplClass = (Class<? extends MutationExecutorService>) custom;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcustomImplClass = classLoaderService.classForName( custom.toString() );\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\treturn customImplClass.getConstructor().newInstance();\n\t\t\t}\n\t\t\tcatch (NoSuchMethodException e) {\n\t\t\t\tthrow new HibernateException(\n\t\t\t\t\t\t\"Could not locate appropriate MutationExecutorService constructor : \" + customImplClass.getName(),\n\t\t\t\t\t\te );\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new HibernateException(\n\t\t\t\t\t\t\"Unable to instantiate custom MutationExecutorService : \" + customImplClass.getName(), e );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static MutationExecutorService discover(ClassLoaderService classLoaderService) {\n\t\tfinal var discovered = classLoaderService.loadJavaServices( MutationExecutorService.class );\n\t\tfinal var iterator = discovered.iterator();\n\t\tif ( iterator.hasNext() ) {\n\t\t\tfinal var selected = iterator.next();\n\t\t\tif ( iterator.hasNext() ) {\n\t\t\t\tthrow new HibernateException(\n\t\t\t\t\t\t\"Multiple MutationExecutorService service registrations found via ServiceLoader; \"","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorServiceInitiator.java#L48-L84","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Add a public no-argument constructor to the custom MutationExecutorService implementation","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","Ensure the class is public and top-level (or public static nested)"],"exampleFix":"// before\nclass MyExecutor implements MutationExecutorService {\n    MyExecutor(Config cfg) { ... }\n}\n\n// after\npublic class MyExecutor implements MutationExecutorService {\n    public MyExecutor() { this(defaultConfig()); }\n    MyExecutor(Config cfg) { ... }\n}","handlingStrategy":"validation","validationCode":"// verify the custom executor is no-arg instantiable before boot\nClass<?> c = Class.forName(props.getProperty(\"hibernate.jdbc.mutation.executor\"));\nif (c.getConstructor() == null) throw new IllegalStateException(\"needs public no-arg ctor\");\n// simpler: assert via reflection that newInstance() succeeds","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Custom Hibernate service classes need public no-arg constructors","Cover custom services with a boot smoke test in CI","Prefer passing an instance when the API allows it"],"tags":["boot","service-loader","customization","reflection","hibernate"],"backgroundTag":"missing-noarg-constructor","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}