由于BeanExpressionException导致字段解析失败,因此创建bean时出错

时间:2016-08-25 11:44:11

标签: java spring spring-el

我有一个spring.xml,它有bean定义,使用rabbit mq的表达式语言

<bean id="rabbitMQ.connectionFactory" class="com.rabbitmq.client.ConnectionFactory">
    <property name="host" value="#{@'rabbitMQ.server'}"/>
</bean>
<bean id="rabbitMQ.joinPoint" class="com.stratasync.eventbus.impl.JoinPoint">
    <description>Helper bean to make RabbitMQ publisher and subscriber reuse same settings</description>
    <property name="connectionFactory" ref="rabbitMQ.connectionFactory"/>
    <property name="queueName" value="#{@'rabbitMQ.queueName'}"/>
    <property name="exchangeName" value="#{@'rabbitMQ.exchangeName'}"/><!-- user.name must not be on production environment-->
    <property name="exchangeKind" value="#{T(com.stratasync.eventbus.impl.ExchangeKind).topic}"/>
</bean>
<bean id="cumulusUI.eventPublisher" class="com.stratasync.eventbus.impl.RabbitMessageQueuePublisher">
    <property name="joinPoint" ref="rabbitMQ.joinPoint"/>
</bean>


 <!-- Cache clean messaging configuration -->

<bean id="rabbitMQ.broadcastJoinPoint" class="com.stratasync.eventbus.impl.JoinPoint" abstract="true">
    <property name="connectionFactory" ref="rabbitMQ.connectionFactory"/>
    <property name="exchangeName" value="#{@'rabbitMQ.exchangeName' + '.broadcast'}"/>
    <property name="exchangeKind" value="#{T(com.stratasync.eventbus.impl.ExchangeKind).fanout}"/>
</bean>

获得以下运行时异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitMQ.broadcastJoinPoint$child#6be311bc' defined in ServletContext resource [/WEB-INF/spring/cumulus-mq.xml]: Cannot resolve reference to bean 'rabbitMQ.connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitMQ.connectionFactory' defined in ServletContext resource [/WEB-INF/spring/cumulus-mq.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.IllegalArgumentException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
... 59 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitMQ.connectionFactory' defined in ServletContext resource [/WEB-INF/spring/cumulus-mq.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.IllegalArgumentException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 65 more
Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.IllegalArgumentException
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142)
at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1306)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:211)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:183)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
... 71 more
Caused by: java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:110)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:85)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1051)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:955)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.expression.BeanFactoryResolver.resolve(BeanFactoryResolver.java:44)
at org.springframework.expression.spel.ast.BeanReference.getValueInternal(BeanReference.java:48)
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.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139)
... 77 more

之前它在Spring 3.x上运行良好,但在Spring 4.x之后,Java8升级得到了BeanExpressionException。任何人都指导我如何解决这个问题。帮助会被贬低!!!

0 个答案:

没有答案