hibernate/hibernate-orm · error · BeanIntrospectionException

Error delegating bean info use

Error message

Error delegating bean info use

What it means

visitBeanInfo obtains a BeanInfo via java.beans.Introspector and then hands it to your delegate. If the delegate throws a reflective InvocationTargetException, the target exception is unwrapped and wrapped into BeanIntrospectionException with this message. Introspection itself succeeded; the failure is inside your callback, and getCause() carries the original target exception.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/util/beans/BeanInfoHelper.java:91

		visitBeanInfo( beanClass, stopClass, delegate );
	}

	public static void visitBeanInfo(Class<?> beanClass, BeanInfoDelegate delegate) {
		visitBeanInfo( beanClass, Object.class, delegate );
	}

	public static void visitBeanInfo(Class<?> beanClass, Class<?> stopClass, BeanInfoDelegate delegate) {
		try {
			final BeanInfo info = getBeanInfo( beanClass, stopClass );
			try {
				delegate.processBeanInfo( info );
			}
			catch ( RuntimeException e ) {
				throw e;
			}
			catch ( InvocationTargetException e ) {
				throw new BeanIntrospectionException( "Error delegating bean info use", e.getTargetException() );
			}
			catch ( Exception e ) {
				throw new BeanIntrospectionException( "Error delegating bean info use", e );
			}
		}
		catch ( BeanIntrospectionException e ) {
			throw e;
		}
		catch ( Exception e ) {
			throw new BeanIntrospectionException( "Unable to determine bean info from class [" + beanClass.getName() + "]", e );
		}
	}

	public static <T> T visitBeanInfo(Class<?> beanClass, ReturningBeanInfoDelegate<T> delegate) {
		return visitBeanInfo( beanClass, null, delegate );
	}

	public static <T> T visitBeanInfo(Class<?> beanClass, Class<?> stopClass, ReturningBeanInfoDelegate<T> delegate) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Read getCause() (the InvocationTargetException's target) to find the real failing invocation, then fix the bean or the callback logic.
  2. Wrap reflective calls inside the delegate and rethrow a contextual RuntimeException — visitBeanInfo passes RuntimeExceptions through untouched, giving clearer errors.
  3. Validate PropertyDescriptor presence and accessibility before invoking inside the delegate.

Example fix

// before
BeanInfoHelper.visitBeanInfo(beanClass, info -> {
    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        pd.getReadMethod().invoke(bean); // underlying getter throws -> wrapped
    }
});

// after
BeanInfoHelper.visitBeanInfo(beanClass, info -> {
    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        try {
            pd.getReadMethod().invoke(bean);
        } catch (ReflectiveOperationException e) {
            throw new IllegalStateException("Failed reading property " + pd.getName(), e);
        }
    }
});
Defensive patterns

Strategy: try-catch

Validate before calling

static void safeInvoke(java.lang.reflect.Method m, Object target) throws ReflectiveOperationException {
    // dry-run accessibility check before the delegate runs
    if (!m.canAccess(target)) m.setAccessible(true);
}

Try / catch

try {
    BeanInfoHelper.visitBeanInfo(beanClass, delegate);
} catch (org.hibernate.internal.util.beans.BeanIntrospectionException e) {
    Throwable real = e.getCause(); // InvocationTargetException's target: the actual failure inside the delegate
    // fix the bean or the delegate logic based on 'real'
}

Prevention

When it happens

Trigger: A BeanInfoDelegate whose processBeanInfo reflectively invokes bean methods (e.g., reading values through PropertyDescriptor.getReadMethod().invoke(...)) and the underlying method throws; the InvocationTargetException is caught here and rewrapped.

Common situations: Generic copy/diff utilities built on BeanInfoHelper; delegates invoking getters on beans whose state or access fails; callbacks looking up PropertyDescriptors by name and calling them on malformed beans.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/a2b40db5bc9f9566. Report an issue: GitHub.