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

Spring JIRA | Christoph Strobl | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 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
  2. 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
  3. 0

    Reversed if condition

    GitHub | 1 year ago | evelan
    org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'username' cannot be found on null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I am trying to use a result of method call to a spring bean as a part of the cache key, but that doesn't seem to work. @Inject private KeyCreatorBean keyCreatorBean; @Cacheable(value = "cacheName", key = "{@keyCreatorBean.createKey, #p0}") @Override public List<Examples> getExamples(ExampleId exampleId) { Results in this kind of stack trace: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Field or property 'keyCreatorBean' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:208) at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) at org.springframework.expression.spel.ast.InlineList.getValueInternal(InlineList.java:86) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:88) at org.springframework.cache.interceptor.ExpressionEvaluator.key(ExpressionEvaluator.java:80) at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.generateKey(CacheAspectSupport.java:464)

    Spring JIRA | 5 years ago | Juha Syrjälä
    org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Field or property 'keyCreatorBean' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject'
  6. 0

    Pass parameter to Spring soap interceptor

    Stack Overflow | 5 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. andyglick 4 times, last 4 weeks ago
  2. musketyr 5 times, last 3 months ago
  3. tvrmsmith 1 times, last 3 months ago
  4. gehel 14 times, last 3 months ago
  5. serious2monkeys 1 times, last 3 months ago
9 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