title: spring @Cacheable with Ehcache, spel find null for valid object
body: <p>I have a similar <a href="https://stackoverflow.com/questions/18157058/spring-cacheable-with-spel-key-always-evaluates-to-null/24301049#24301049">problem</a> which but sometimes it works. The error described only happens once in a while.</p>
  
  <p>I am using spring 3.2.5 and ehcache 2.6.5.</p>
  
  <p>Exception trace:</p>
  
  <pre><code>org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Field or property 'applicationID' cannot be found on null
          at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:213)
          at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
          at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:43)
          at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:346)
          at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:82)
          at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
          at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:89)
          at org.springframework.cache.interceptor.ExpressionEvaluator.key(ExpressionEvaluator.java:95)
          at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.generateKey(CacheAspectSupport.java:452)
          at org.springframework.cache.interceptor.CacheAspectSupport.inspectCacheables(CacheAspectSupport.java:281)
          at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:199)
          at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
          at com.sun.proxy.$Proxy85.getMailOrigin(Unknown Source)
          at com.myApplication.MailFilterServiceImpl.isValid(ApplicationServiceImpl.java:134)
  </code></pre>
  
  <p>My caching code is a follows:</p>
  
  <pre><code>MailFilterServiceImpl
      @Cacheable(value="mailClientsCache", key="#mb.applicationID")
          public MailClientBean getMailOrigin(MailBean mb){}
  </code></pre>
  
  <p><strong>When this happens</strong>:
  When I have a jenkins configured to build and autodeploy to tomcat7 / when I use maven to build in the eclipse WS and deploy to tomcat7.</p>
  
  <p><strong>When this works perfectly</strong>:
  After it has failed once, if I edit the MailFilterServiceImpl.java simply with some spaces to make it recompile in eclipse and restart the tomcat7 server.</p>
  
  <p>I need to make it work in a CI scenario.</p>
  
  <p><strong>[Update]</strong>
  Setting compiler option debug:true works around this problem. The optimized doesnt seem to have any say.</p>
  
  <pre><code>&lt;debug&gt;true&lt;/debug&gt;
  &lt;optimize&gt;true&lt;/optimize&gt;
  </code></pre>