hibernate/hibernate-orm · error · ConnectionProviderConfigurationException

DataSource to use was not injected nor specified by 'hiberna

Error message

DataSource to use was not injected nor specified by 'hibernate.connection.datasource'

What it means

Error "DataSource to use was not injected nor specified by 'hibernate.connection.datasource'" thrown in hibernate/hibernate-orm.

Source

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

		}
	}

	@Override
	public void configure(@Nonnull Map<String, Object> configuration) {
		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 ) ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Set 'hibernate.connection.datasource' to the JNDI name of the DataSource
  2. Inject a DataSource into DataSourceConnectionProvider programmatically

When it happens

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