hibernate/hibernate-orm · error · JndiException

Unable to lookup JNDI name

Error message

Unable to lookup JNDI name [${jndiName}]

What it means

JndiServiceImpl.locate wraps a NamingException thrown by InitialContext.lookup for the parsed JNDI name — the name does not exist in the directory or is not accessible. The cause carries the original NamingException.

Solutions

  1. Verify the JNDI name exists in the naming context and the resource is bound
  2. Check the InitialContext environment settings (provider URL, factory)
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

								Environment.JNDI_PREFIX.length() + 1 );
						jndiProperties.put( passThruPropertyName, NullnessUtil.castNonNull( propertyValue ) );
					}
				}
			}
		}

		return jndiProperties;
	}

	@Override
	public Object locate(String jndiName) {
		final var initialContext = buildInitialContext();
		final Name name = parseName( jndiName, initialContext );
		try {
			return initialContext.lookup( name );
		}
		catch ( NamingException e ) {
			throw new JndiException( "Unable to lookup JNDI name [" + jndiName + "]", e );
		}
		finally {
			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 );

View on GitHub (pinned to fad1729dce)