hibernate/hibernate-orm · error · JndiException

JNDI lookups for scheme

Error message

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

What it means

parseName extracted a URI scheme from the JNDI name that is not in the configured list of allowed schemes — a security guard against lookups of unintended protocols (e.g. RMI in an LDAP context). The offending input is the scheme portion of the JNDI name.

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
Defensive patterns

Strategy: validation

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.

Appendix: 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)