我在将应用程序从 spring-integration 4.0.4 迁移到最新的 4.1.0 版本时遇到问题。
替换 jar 后,我的集成上下文将为每个 <recipient-list-router/>
抛出异常。标签。
抛出的异常是 java.lang.ClassCastException
消息是:
Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy62 cannot be cast to org.springframework.integration.context.IntegrationObjectSupport
at org.springframework.config.AbstractSimpleMessageHandlerFactoryBean.createHandlerInternal(AbstractSimpleMessageHandlerFactoryBean.java:130)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.getObject(AbstractSimpleMessageHandlerFactoryBean.java:102)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.getObject(AbstractSimpleMessageHandlerFactoryBean.java:44)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanReagistrySupport.java:168)
... 20 more
我正在使用 Spring-Integration 4.1.0.RELEASE、spring-core 4.1.2.RELEASE,并在 jdk1.8.0_05 上运行。
我的集成 bean 上下文包含两个 <recipient-list-router/>
标签,删除后不会引发此错误。
最佳答案
代码来自AbstractSimpleMessageHandlerFactoryBean
说:
else if(!(this.handler instanceof AbstractReplyProducingMessageHandler)) {
if (logger.isDebugEnabled()) {
logger.debug("adviceChain can only be set to AbstractReplyProducingMessageHandler or its subclass, "
+ ((IntegrationObjectSupport) this.handler).getComponentName() + " doesn't support it.");
}
}
那么,让我们切换 debug
对于org.springframework.integration
类别!
从另一方面来说,我同意这是一个错误,因为如果我们的 messageHandler
是 Proxy
我们不能简单地将其转换为 IntegrationObjectSupport
。
所以,请随意提出 JIRA关于此事的票。
从另一面来看,不清楚为什么删除 <recipient-list-router/>
驱逐问题...
因为<recipient-list-router/>
不支持<request-handler-advice-chain>
。
我同意我们在 4.1 中引入了 RecipientListRouterManagement
如果您使用 JMX,特殊的 MBean 将注册为 RecipientListRouter
最后一个变成 Proxy
,但尚不清楚该代理与 request-handler-advice-chain
有何关系。记录消息...
如果您可以从 AbstractSimpleMessageHandlerFactoryBean
调试该行,那就太好了并向我们展示真正的对象 Proxy
.
请显示更多 StackTrace 。也许我们可以看到更多背景来找出原因的根源。
谢谢!
关于java - Spring Integration 4.1.0 迁移问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26958018/