hibernate/hibernate-orm · error · JndiException

JNDI lookups for scheme '${scheme}' are not allowed

Error message

JNDI lookups for scheme '${scheme}' are not allowed

What it means

Error "JNDI lookups for scheme '${scheme}' are not allowed" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java:114

			cleanUp( initialContext );
		}
	}

	private InitialContext buildInitialContext() {
		try {
			return initialContextSettings.size() == 0 ? new InitialContext() : new InitialContext( initialContextSettings );
		}
		catch ( NamingException e ) {
			throw new JndiException( "Unable to open InitialContext", e );
		}
	}

	private Name parseName(String jndiName, Context context) {
		try {
			final URI uri = new URI( jndiName );
			final String scheme = uri.getScheme();
			if ( scheme != null && (! allowedScheme( scheme ) ) ) {
				throw new JndiException( "JNDI lookups for scheme '" + scheme + "' are not allowed" );
			}
		}
		catch (URISyntaxException e) {
			//Ok
		}
		try {
			return context.getNameParser( "" ).parse( jndiName );
		}
		catch ( InvalidNameException e ) {
			throw new JndiNameException( "JNDI name [" + jndiName + "] was not valid", e );
		}
		catch ( NamingException e ) {
			throw new JndiException( "Error parsing JNDI name [" + jndiName + "]", e );
		}
	}

	private static boolean allowedScheme(final String scheme) {
		return switch ( scheme ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use an allowed JNDI scheme, or add the scheme to the allowed schemes configuration
  2. Perform the lookup without a URL scheme prefix

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java:114 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/980d51c9e351242c. Report an issue: GitHub.