org.springframework.expression.spel.SpelEvaluationException: EL1072E:(pos 0): An exception occurred whilst evaluating a compiled expression

Spring JIRA | Christoph Strobl | 2 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0
    samebug tip
    You can only access stepExecutionContext within a bean defined in the scope = "step", add "scope = "step"" to your bean declaration.
  2. 0
    samebug tip
    Flow files only know how to work with Spring Beans, annotate ManagedBean with @Component('serviceProviderSubscriptionBB') or declare the managed bean directly on flow with <var name="serviceProviderSubscriptionBB" class="the full name of your class"/>
  3. 0

    Calling registered custom functions does not work once compiled SpEL expression is used. (tried with 4.1, 4.1.1 and 4.1.2 snapshot) {noformat} org.springframework.expression.spel.SpelEvaluationException: EL1072E:(pos 0): An exception occurred whilst evaluating a compiled expression at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:180) {noformat} The below tests passes once {{doFormat}} is registered as {{context.registerFunction("doFormat", String.class.getDeclaredMethod("format", String.class, Object[].class));}} but fails when using some custom class. {code:java} Test public void compiledExpressionShouldWorkWhenUsingCustomFunctionWithVarargs() throws NoSuchMethodException, SecurityException { SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, this .getClass().getClassLoader())); SpelExpression expression = parser.parseRaw("#doFormat([0], #arg)"); StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { "hey %s" }); context.registerFunction("doFormat", DelegatingStringFormat.class.getDeclaredMethod("format", String.class, Object[].class)); context.setVariable("arg", "there"); expression.setEvaluationContext(context); assertThat(expression.getValue(String.class), is("hey there")); assertThat(expression.getValue(String.class), is("hey there")); // have to call it 3 time to fail assertThat(expression.getValue(String.class), is("hey there")); } static class DelegatingStringFormat { static String format(String s, Object... args) { return String.format(s, args); } } {code} The above will work once we change the method signature of {{DelegatingStringFormat.format}} to {{static String format(String s, Object[] args)}}. Another failing sample not using varargs: {code:java} @Test public void compiledExpressionShouldWorkWhenUsingCustomFunction() throws NoSuchMethodException, SecurityException { SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, this.getClass().getClassLoader())); SpelExpression expression = parser.parseRaw("#doCompare([0], #arg)"); StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { "1" }); context.registerFunction("doCompare", SomeCompareMethod.class.getDeclaredMethod("compare", Object.class, Object.class)); context.setVariable("arg", "2"); expression.setEvaluationContext(context); assertThat(expression.getValue(Integer.class), is(-1)); assertThat(expression.getValue(Integer.class), is(-1)); // have to call it 3 time to fail assertThat(expression.getValue(Integer.class), is(-1)); } static class SomeCompareMethod { static int compare(Object o1, Object o2) { return new ComparableComparator().compare(o1, o2); } } {code}

    Spring JIRA | 2 years ago | Christoph Strobl
    org.springframework.expression.spel.SpelEvaluationException: EL1072E:(pos 0): An exception occurred whilst evaluating a compiled expression
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Calling registered custom functions does not work once compiled SpEL expression is used. (tried with 4.1, 4.1.1 and 4.1.2 snapshot) {noformat} org.springframework.expression.spel.SpelEvaluationException: EL1072E:(pos 0): An exception occurred whilst evaluating a compiled expression at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:180) {noformat} The below tests passes once {{doFormat}} is registered as {{context.registerFunction("doFormat", String.class.getDeclaredMethod("format", String.class, Object[].class));}} but fails when using some custom class. {code:java} Test public void compiledExpressionShouldWorkWhenUsingCustomFunctionWithVarargs() throws NoSuchMethodException, SecurityException { SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, this .getClass().getClassLoader())); SpelExpression expression = parser.parseRaw("#doFormat([0], #arg)"); StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { "hey %s" }); context.registerFunction("doFormat", DelegatingStringFormat.class.getDeclaredMethod("format", String.class, Object[].class)); context.setVariable("arg", "there"); expression.setEvaluationContext(context); assertThat(expression.getValue(String.class), is("hey there")); assertThat(expression.getValue(String.class), is("hey there")); // have to call it 3 time to fail assertThat(expression.getValue(String.class), is("hey there")); } static class DelegatingStringFormat { static String format(String s, Object... args) { return String.format(s, args); } } {code} The above will work once we change the method signature of {{DelegatingStringFormat.format}} to {{static String format(String s, Object[] args)}}. Another failing sample not using varargs: {code:java} @Test public void compiledExpressionShouldWorkWhenUsingCustomFunction() throws NoSuchMethodException, SecurityException { SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, this.getClass().getClassLoader())); SpelExpression expression = parser.parseRaw("#doCompare([0], #arg)"); StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { "1" }); context.registerFunction("doCompare", SomeCompareMethod.class.getDeclaredMethod("compare", Object.class, Object.class)); context.setVariable("arg", "2"); expression.setEvaluationContext(context); assertThat(expression.getValue(Integer.class), is(-1)); assertThat(expression.getValue(Integer.class), is(-1)); // have to call it 3 time to fail assertThat(expression.getValue(Integer.class), is(-1)); } static class SomeCompareMethod { static int compare(Object o1, Object o2) { return new ComparableComparator().compare(o1, o2); } } {code}

    Spring JIRA | 2 years ago | Christoph Strobl
    org.springframework.expression.spel.SpelEvaluationException: EL1072E:(pos 0): An exception occurred whilst evaluating a compiled expression
  6. 0

    Pass parameter to Spring soap interceptor

    Stack Overflow | 7 months ago | ViratKohli
    org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'headers' cannot be found on object of type 'org.spri ngframework.beans.factory.config.BeanExpressionContext' - maybe not public?

  1. tomthomas 3 times, last 1 month ago
  2. batwalrus76 2 times, last 1 month ago
  3. andyglick 4 times, last 2 months ago
  4. musketyr 5 times, last 4 months ago
  5. tvrmsmith 1 times, last 4 months ago
11 more registered users
49 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.expression.spel.SpelEvaluationException

    EL1072E:(pos 0): An exception occurred whilst evaluating a compiled expression

    at org.springframework.expression.spel.standard.SpelExpression.getValue()
  2. Spring Expression Language (SpEL)
    SpelExpression.getValue
    1. org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:180)
    1 frame