从Spring 4.1.1升级到4.3.3后,Spring表达式无法正常工作

时间:2016-09-28 08:13:30

标签: spring

我们想从spring 4.1.1升级到4.3.3但是我们的xml中的一些spring表达式有问题,这些表达式在4.1.1中有效但在后面的版本中没有。

我们在评估环境中创建一个变量,如下所示:

evaluationContextAccessor.getEvalContext().setVariable("report", report)  

然后在xml配置文件中,我们有一个原型范围的bean:

<property name="resource" value="#{#report.artifact}"/> 

报表对象中的工件是资源

升级后我们得到的例外是:

failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'artifact' cannot be found on null
    at uk.org.ppa.dispatcherapplications.event.ReportCompletedAdaptor.onApplicationEvent(ReportCompletedAdaptor.java:34)
    at uk.org.ppa.dispatcherapplications.event.ReportCompletedAdaptor.onApplicationEvent(ReportCompletedAdaptor.java:1)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)
    at uk.org.ppa.dispatcherapplications.ReportRunner.fireReportCompletedEvent(ReportRunner.java:364)
    at uk.org.ppa.dispatcherapplications.ReportRunner.doEvent(ReportRunner.java:347)
    at uk.org.ppa.dispatcherapplications.ReportRunner.generateReport(ReportRunner.java:252)
    at uk.org.ppa.dispatcherapplications.ReportRunner.generateReport(ReportRunner.java:211)
    at uk.org.ppa.dispatcherapplications.ReportRunner.createReport(ReportRunner.java:195)
    at uk.org.ppa.dispatcherapplications.MultiReportRunner.processReport(MultiReportRunner.java:88)
    at uk.org.ppa.dispatcherapplications.MultiReportRunner.run(MultiReportRunner.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy17.run(Unknown Source)
    at uk.org.ppa.dispatcherapplications.AbstractRunnerWithPeriodTypeParameter.main(AbstractRunnerWithPeriodTypeParameter.java:119)

调试时,评估上下文确实包含报表对象作为变量

我认为在4.1.1

之后必须改变一些东西

任何想法都会感激不尽

0 个答案:

没有答案