使用Ehcache弹出@Cacheable,spel为有效对象找到null [英] spring @Cacheable with Ehcache, spel find null for valid object
问题描述
我有一个类似的问题但有时它有效。描述的错误只会偶尔发生一次。
I have a similar problem which but sometimes it works. The error described only happens once in a while.
我使用的是spring 3.2.5和ehcache 2.6.5。
I am using spring 3.2.5 and ehcache 2.6.5.
异常跟踪:
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)
我的缓存代码如下:
MailFilterServiceImpl
@Cacheable(value="mailClientsCache", key="#mb.applicationID")
public MailClientBean getMailOrigin(MailBean mb){}
发生这种情况时:
当我将jenkins配置为构建并自动部署到tomcat7 /当我使用maven构建eclipse WS并部署到tomcat7时。
When this happens: 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.
当这完全有效时:
一旦失败一次,如果我编辑MailFilterServiceImpl.java只需要一些空格来重新编译eclipse并重新启动tomcat7服务器。
When this works perfectly: 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.
我需要让它在CI场景中运行。
I need to make it work in a CI scenario.
[更新]
设置编译器选项debug:true可解决此问题。优化似乎没有任何发言权。
[Update] Setting compiler option debug:true works around this problem. The optimized doesnt seem to have any say.
<debug>true</debug>
<optimize>true</optimize>
推荐答案
你的描述清楚地表明:它不起作用当您使用 javac
进行编译时,它确实可以与Eclipse编译器 ecj
一起使用。您可能正在编译而没有调试信息。
Your description makes one thing clear: It does not work when you compile with javac
, but it does work with the Eclipse compiler ecj
. You might be compiling without debugging information.
这篇关于使用Ehcache弹出@Cacheable,spel为有效对象找到null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!