hibernate/hibernate-orm · error · HibernateException

Could not instantiate connection provider

Error message

Could not instantiate connection provider [{}]

What it means

Wraps instantiation failure of a ConnectionProvider selected by name through the StrategySelector; the named provider class could not be constructed (missing constructor, strategy not registered, or constructor threw). The cause holds the underlying exception.

Solutions

  1. Ensure the connection provider class has an accessible no-arg constructor and is on the classpath
  2. Check the provider configuration for typos and missing dependencies
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java:139 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java:139

	}

	private static Class<? extends ConnectionProvider> connectionProviderClass(Class<?> providerClass) {
		if ( !ConnectionProvider.class.isAssignableFrom( providerClass ) ) {
			throw new ConnectionProviderConfigurationException( "Class '" + providerClass.getName()
																+ "' does not implement 'ConnectionProvider'" );
		}
		return providerClass.asSubclass( ConnectionProvider.class );
	}

	private ConnectionProvider instantiateNamedConnectionProvider(
			String providerName, StrategySelector strategySelector, BeanContainer beanContainer) {
		CONNECTION_PROVIDER_LOGGER.instantiatingExplicitConnectionProvider( providerName );
		final var providerClass = strategySelector.selectStrategyImplementor( ConnectionProvider.class, providerName );
		try {
			return instantiateExplicitConnectionProvider( providerClass, beanContainer );
		}
		catch (Exception e) {
			throw new HibernateException( "Could not instantiate connection provider [" + providerName + "]", e );
		}
	}

	private ConnectionProvider instantiateConnectionProvider(
			Map<String, Object> configurationValues, StrategySelector strategySelector, BeanContainer beanContainer) {
		if ( configurationValues.containsKey( DATASOURCE ) ) {
			return new DataSourceConnectionProvider();
		}

		final var singleRegisteredProvider = getSingleRegisteredProvider( strategySelector );
		if ( singleRegisteredProvider != null ) {
			try {
				return singleRegisteredProvider.getConstructor().newInstance();
			}
			catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException e) {
				throw new HibernateException( "Could not instantiate singular-registered ConnectionProvider", e );
			}
		}

View on GitHub (pinned to fad1729dce)