{"record":{"id":"418ced33afdd7008","repo":"hibernate/hibernate-orm","slug":"unable-to-instantiate-named-dialect-resolver-res","errorCode":null,"errorMessage":"Unable to instantiate named dialect resolver [<resolverImplName>]","messagePattern":"Unable to instantiate named dialect resolver \\[<resolverImplName>\\]","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"critical","filePath":"hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java","lineNumber":65,"sourceCode":"\tprivate void applyCustomerResolvers(\n\t\t\tDialectResolverSet resolverSet,\n\t\t\tServiceRegistryImplementor registry,\n\t\t\tMap<?,?> configurationValues) {\n\t\tfinal String resolverImplNames = (String) configurationValues.get( AvailableSettings.DIALECT_RESOLVERS );\n\n\t\tfinal ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );\n\t\tif ( StringHelper.isNotEmpty( resolverImplNames ) ) {\n\t\t\tfor ( String resolverImplName : StringHelper.split( \", \\n\\r\\f\\t\", resolverImplNames ) ) {\n\t\t\t\ttry {\n\t\t\t\t\tfinal DialectResolver dialectResolver = (DialectResolver)\n\t\t\t\t\t\t\tclassLoaderService.classForName( resolverImplName ).newInstance();\n\t\t\t\t\tresolverSet.addResolver( dialectResolver );\n\t\t\t\t}\n\t\t\t\tcatch (HibernateException e) {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tthrow new ServiceException( \"Unable to instantiate named dialect resolver [\" + resolverImplName + \"]\", e );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfinal Collection<DialectResolver> resolvers = classLoaderService.loadJavaServices( DialectResolver.class );\n\t\tresolverSet.addDiscoveredResolvers( resolvers );\n\t}\n}\n","sourceCodeStart":47,"sourceCodeEnd":74,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java#L47-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nhibernate.dialect_resolvers=com.example.OldResolverName   # renamed class -> ServiceException\n\n# after\nhibernate.dialect_resolvers=com.example.MyDatabaseDialectResolver\n\npublic class MyDatabaseDialectResolver implements DialectResolver {\n    public MyDatabaseDialectResolver() {} // public no-arg ctor\n    @Override public Dialect resolveDialect(DialectResolutionInfo info) { ... }\n}","handlingStrategy":"validation","validationCode":"// validate every configured resolver class at startup\nfor (String name : resolverNames.split(\"[,\\\\s]+\")) {\n    Class<?> c = Class.forName(name);\n    if ( !DialectResolver.class.isAssignableFrom(c)\n            || c.getConstructor() == null ) {\n        throw new ConfigurationException(\"Bad hibernate.dialect_resolvers entry: \" + name);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    registryBuilder.build();\n} catch (ServiceException e) {\n    if ( e.getMessage() != null && e.getMessage().contains(\"dialect resolver\") ) {\n        throw new ConfigurationException(\"Fix hibernate.dialect_resolvers entries\", e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["hibernate","dialect","resolver","configuration","reflection","bootstrap"],"backgroundTag":"dialect-resolver-instantiation-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}