hibernate/hibernate-orm · error · ConnectionProviderConfigurationException

Unable to determine appropriate DataSource to use

Error message

Unable to determine appropriate DataSource to use

What it means

Error "Unable to determine appropriate DataSource to use" thrown in hibernate/hibernate-orm.

Source

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

		if ( dataSource == null ) {
			final Object dataSourceSetting = configuration.get( DATASOURCE );
			if ( dataSourceSetting instanceof DataSource instance ) {
				dataSource = instance;
			}
			else if ( dataSourceSetting instanceof String jndiName ) {
				dataSourceJndiName = jndiName;
				if ( jndiService == null ) {
					throw new ConnectionProviderConfigurationException( "Unable to locate JndiService to lookup Datasource" );
				}
				dataSource = (DataSource) jndiService.locate( jndiName );
			}
			else {
				throw new ConnectionProviderConfigurationException(
						"DataSource to use was not injected nor specified by '" + DATASOURCE + "'" );
			}
		}
		if ( dataSource == null ) {
			throw new ConnectionProviderConfigurationException( "Unable to determine appropriate DataSource to use" );
		}

		final Integer loginTimeout = getInteger( LOGIN_TIMEOUT, configuration );
		if ( loginTimeout != null ) {
			try {
				dataSource.setLoginTimeout( loginTimeout );
			}
			catch (SQLException e) {
				CONNECTION_INFO_LOGGER.couldNotSetLoginTimeout( e );
			}
		}

		if ( configuration.containsKey( JdbcSettings.AUTOCOMMIT ) ) {
			CONNECTION_INFO_LOGGER.ignoredSetting( JdbcSettings.AUTOCOMMIT,
					DataSourceConnectionProvider.class );
		}
		if ( configuration.containsKey( JdbcSettings.ISOLATION ) ) {
			CONNECTION_INFO_LOGGER.ignoredSetting( JdbcSettings.ISOLATION,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Configure a DataSource explicitly via 'hibernate.connection.datasource' or injection
  2. Check that the configured JNDI name resolves to a javax.sql.DataSource

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DataSourceConnectionProvider.java:111 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/bab84471b91a27c5. Report an issue: GitHub.