hibernate/hibernate-orm · critical · ServiceException
Unable to instantiate named dialect resolver [<resolverImplN
Error message
Unable to instantiate named dialect resolver [<resolverImplName>]
What it means
DialectResolverInitiator parses the hibernate.dialect_resolvers setting (comma/whitespace-separated class names), and for each entry uses ClassLoaderService.classForName(...).newInstance() to build a DialectResolver. Any failure other than a HibernateException - class not found, does not implement DialectResolver (ClassCastException), missing no-arg constructor, or constructor throwing - is wrapped in ServiceException.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java:65
private void applyCustomerResolvers(
DialectResolverSet resolverSet,
ServiceRegistryImplementor registry,
Map<?,?> configurationValues) {
final String resolverImplNames = (String) configurationValues.get( AvailableSettings.DIALECT_RESOLVERS );
final ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );
if ( StringHelper.isNotEmpty( resolverImplNames ) ) {
for ( String resolverImplName : StringHelper.split( ", \n\r\f\t", resolverImplNames ) ) {
try {
final DialectResolver dialectResolver = (DialectResolver)
classLoaderService.classForName( resolverImplName ).newInstance();
resolverSet.addResolver( dialectResolver );
}
catch (HibernateException e) {
throw e;
}
catch (Exception e) {
throw new ServiceException( "Unable to instantiate named dialect resolver [" + resolverImplName + "]", e );
}
}
}
final Collection<DialectResolver> resolvers = classLoaderService.loadJavaServices( DialectResolver.class );
resolverSet.addDiscoveredResolvers( resolvers );
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Verify each listed class implements DialectResolver and has a public no-arg constructor
- Correct or remove the failing entry from hibernate.dialect_resolvers
- Prefer ServiceLoader registration (META-INF/services/org.hibernate.engine.jdbc.dialect.spi.DialectResolver) which avoids fragile name lists
- Check the nested cause to identify which entry and why
Example fix
# before
hibernate.dialect_resolvers=com.example.OldResolverName # renamed class -> ServiceException
# after
hibernate.dialect_resolvers=com.example.MyDatabaseDialectResolver
public class MyDatabaseDialectResolver implements DialectResolver {
public MyDatabaseDialectResolver() {} // public no-arg ctor
@Override public Dialect resolveDialect(DialectResolutionInfo info) { ... }
} Defensive patterns
Strategy: validation
Validate before calling
// validate every configured resolver class at startup
for (String name : resolverNames.split("[,\\s]+")) {
Class<?> c = Class.forName(name);
if ( !DialectResolver.class.isAssignableFrom(c)
|| c.getConstructor() == null ) {
throw new ConfigurationException("Bad hibernate.dialect_resolvers entry: " + name);
}
} Try / catch
try {
registryBuilder.build();
} catch (ServiceException e) {
if ( e.getMessage() != null && e.getMessage().contains("dialect resolver") ) {
throw new ConfigurationException("Fix hibernate.dialect_resolvers entries", e);
}
throw e;
} Prevention
- Prefer META-INF/services registration of DialectResolver over the class-name property - no brittle name lists
- Keep custom resolvers covered by a build-time instantiation test
When it happens
Trigger: Setting hibernate.dialect_resolvers to a class name that does not exist, is abstract, lacks a public no-arg constructor, or does not implement org.hibernate.engine.jdbc.dialect.spi.DialectResolver; whitespace-separated lists where one entry is broken fail the whole initiator.
Common situations: Registering a custom resolver for an unsupported database but forgetting to include its jar on the runtime classpath; renaming the resolver class without updating the property; constructor visibility lost after refactoring.
Related errors
- Could not instantiate named dialect class [%s]
- Could not instantiate event listener '{}'
- Unable to instantiate StatementObserver - {}
- Unable to construct requested dialect [<dialectReference>]
- Unable to determine Dialect without JDBC metadata (please se
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/418ced33afdd7008.
Report an issue: GitHub.