org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 4): Method call: Attempted to call method toString() on null context object

Spring JIRA | Satish | 2 years ago
  1. 0

    I have this very simple repository setup. {code:java} public interface CompanyRepository extends CrudRepository<CompanyModel, Integer> { @Override @Cacheable(value = "comp", key = "#id.toString()") CompanyModel findOne(Integer id); } {code} When I add the {{@Cachable}} annotation to cache the record in redis, I get a null pointer exception. Without the {{@Cachable}}, the record is retrieved without any issues. {noformat} org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 4): Method call: Attempted to call method toString() on null context object at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:137) at org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:68) at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:63) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:103) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94) at org.springframework.cache.interceptor.ExpressionEvaluator.key(ExpressionEvaluator.java:103) at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.generateKey(CacheAspectSupport.java:429) at org.springframework.cache.interceptor.CacheAspectSupport.generateKey(CacheAspectSupport.java:325) at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:278) at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:201) at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:181) at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:60) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy96.findOne(Unknown Source) {noformat}

    Spring JIRA | 2 years ago | Satish
    org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 4): Method call: Attempted to call method toString() on null context object
  2. 0

    I have this very simple repository setup. {code:java} public interface CompanyRepository extends CrudRepository<CompanyModel, Integer> { @Override @Cacheable(value = "comp", key = "#id.toString()") CompanyModel findOne(Integer id); } {code} When I add the {{@Cachable}} annotation to cache the record in redis, I get a null pointer exception. Without the {{@Cachable}}, the record is retrieved without any issues. {noformat} org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 4): Method call: Attempted to call method toString() on null context object at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:137) at org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:68) at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:63) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:103) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94) at org.springframework.cache.interceptor.ExpressionEvaluator.key(ExpressionEvaluator.java:103) at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.generateKey(CacheAspectSupport.java:429) at org.springframework.cache.interceptor.CacheAspectSupport.generateKey(CacheAspectSupport.java:325) at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:278) at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:201) at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:181) at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:60) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy96.findOne(Unknown Source) {noformat}

    Spring JIRA | 2 years ago | Satish
    org.springframework.expression.spel.SpelEvaluationException: EL1011E:(pos 4): Method call: Attempted to call method toString() on null context object
  3. 0

    spring @Cacheable with Ehcache, spel find null for valid object

    Stack Overflow | 2 years ago | JayabalanAaron
    org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Field or property 'applicationID' cannot be found on null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring Caching key generator

    Stack Overflow | 3 years ago | user3561481
    org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'personId' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject'
  6. 0

    @Cacheable via Spring aop - how generate unique cache key

    Stack Overflow | 3 years ago | Denis Cucchietti
    org.springframework.expression.spel.SpelEvaluationException: EL1030E:(pos 0): The operator 'ADD' is not supported between objects of type 'java.lang.Class' and 'null'

  1. Malcshour 9 times, last 6 months ago
  2. serious2monkeys 2 times, last 4 months ago
  3. musketyr 5 times, last 6 days ago
  4. tvrmsmith 1 times, last 6 days ago
  5. gehel 14 times, last 6 days ago
8 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

    EL1011E:(pos 4): Method call: Attempted to call method toString() on null context object

    at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe()
  2. Spring Expression Language (SpEL)
    SpelExpression.getValue
    1. org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:137)
    2. org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:68)
    3. org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:63)
    4. org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
    5. org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:103)
    6. org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94)
    6 frames
  3. Spring Context
    CacheInterceptor.invoke
    1. org.springframework.cache.interceptor.ExpressionEvaluator.key(ExpressionEvaluator.java:103)
    2. org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.generateKey(CacheAspectSupport.java:429)
    3. org.springframework.cache.interceptor.CacheAspectSupport.generateKey(CacheAspectSupport.java:325)
    4. org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:278)
    5. org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:201)
    6. org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:181)
    7. org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:60)
    7 frames
  4. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    2 frames
  5. com.sun.proxy
    $Proxy96.findOne
    1. com.sun.proxy.$Proxy96.findOne(Unknown Source)
    1 frame