diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java index 0387b65ef33..0aeeee375b3 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java @@ -18,6 +18,7 @@ package org.springframework.expression.spel.ast; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.StringJoiner; @@ -145,8 +146,10 @@ public class FunctionReference extends SpelNodeImpl { return new TypedValue(result, new TypeDescriptor(new MethodParameter(method, -1)).narrow(result)); } catch (Exception ex) { - throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_FUNCTION_CALL, - this.name, ex.getMessage()); + Throwable cause = ((ex instanceof InvocationTargetException ite && ite.getCause() != null) ? + ite.getCause() : ex); + throw new SpelEvaluationException(getStartPosition(), cause, SpelMessage.EXCEPTION_DURING_FUNCTION_CALL, + this.name, cause.getMessage()); } finally { if (compilable) {