JBoss Fuse 6.3中CXF端点解析失败问题求助
JBoss Fuse 6.3部署Camel CXF Web服务陷入递归循环,部署失败
我在JBoss Fuse 6.3上部署Camel CXF Web服务时遇到了一个棘手的问题——本地实例运行完全正常,但部署到其他实例时直接失败,还陷入了递归循环,日志里反复出现相同的异常。
环境版本信息
- Apache Camel:2.17.0
- JBoss EAP:6.4
端点配置
<cxf:cxfEndpoint id="ApiReadEndpoint" xmlns:nms="urn:company:esb:services:CoreInsuranceRead:v01" address="{{esb.api.outread.contextpathurl}}" wsdlURL="wsdl/aoiRead/CoreInsuranceReadInterface.wsdl" endpointName="nms:SysTest" serviceName="nms:CoreInsuranceReadService"> <cxf:properties> <entry key="dataFormat" value="PAYLOAD" /> <entry key="ws-security.validate.token" value="false" /> </cxf:properties> <cxf:inInterceptors> <ref bean="wss4jInInterceptor" /> <ref bean="authenticationInterceptor" /> <ref bean="authorizationInterceptor" /> </cxf:inInterceptors> </cxf:cxfEndpoint>
Camel路由
<route id="APIReadServiceRoute" streamCache="true"> <from id="ApiReadEndpoint" uri="cxf:bean:ApiReadEndpoint"/> <doTry id="_doTry1"> <to id="_to1" uri="direct:ClaimRead"/> <doCatch id="_doCatch1"> <exception>java.lang.Exception</exception> <handled> <constant>true</constant> </handled> </doCatch> </doTry> </route>
错误日志片段
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: cxf://bean:ApiReadEndpoint due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ApiReadEndpoint': FactoryBean threw exception on object creation; nested exception is org.apache.camel.ResolveEndpointFailedException: at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:589) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310] at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:55) at org.apache.camel.spring.CamelEndpointFactoryBean.getObject(CamelEndpointFactoryBean.java:60) [camel-spring-2.17.0.redhat-630310.jar:2.17.0.redhat-630310] at org.apache.camel.spring.CamelEndpointFactoryBean.getObject(CamelEndpointFactoryBean.java:38) [camel-spring-2.17.0.redhat-630310.jar:2.17.0.redhat-630310] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:166) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1467) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1131) [spring-context-3.2.18.RELEASE.jar:3.2.18.RELEASE] at org.apache.camel.spring.spi.ApplicationContextRegistry.lookupByNameAndType(ApplicationContextRegistry.java:47) [camel-spring-2.17.0.redhat-630310.jar:2.17.0.redhat-630310] at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310] at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:137) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310] at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:157) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
排查与解决思路
从日志核心错误来看,问题出在Camel无法解析cxf://bean:ApiReadEndpoint端点,根源是创建ApiReadEndpoint这个Bean时抛出异常,进而引发了递归循环(解析端点需要创建Bean,创建Bean又需要解析端点)。结合本地正常、其他实例失败的情况,给你几个具体的排查方向:
1. 检查Bean加载顺序与循环依赖
本地运行正常大概率说明配置逻辑没问题,但其他实例可能因为Bean加载顺序不同触发了循环依赖。
- 确认
wss4jInInterceptor、authenticationInterceptor、authorizationInterceptor这些拦截器Bean是否在ApiReadEndpoint之前初始化。如果拦截器依赖了Camel上下文或端点相关Bean,就会形成循环。 - 可以给拦截器Bean加上
depends-on属性,明确指定依赖的Bean,或者调整配置文件中Bean的定义顺序,让拦截器先被加载。
2. 验证占位符属性的正确性
你的端点地址用了{{esb.api.outread.contextpathurl}}占位符,要确认其他实例的配置文件中这个属性是否正确配置:
- 检查属性名有没有拼写错误,值是否符合格式要求。如果属性无法被正确替换,CXF端点创建会失败,进而触发重复尝试的递归循环。
- 可以开启Spring属性替换的调试日志,观察这个属性是否被正确解析。
3. 确认类路径与依赖一致性
本地和其他实例的类路径可能存在差异:
- 检查其他实例的JBoss Fuse是否包含了所有必需的CXF、Camel依赖包,有没有版本冲突(比如某个依赖在本地存在但其他实例缺失,或者版本不匹配)。
- 检查部署的Bundle是否正确导入了
org.apache.camel.component.cxf、org.apache.cxf.ws.security等必要的包,避免因类找不到导致Bean创建失败。
4. 简化配置排查问题根源
先尝试简化配置,定位问题点:
- 暂时移除所有拦截器,重新部署看是否正常。如果能正常部署,再逐个添加拦截器,排查是哪个拦截器引发的问题。
- 查看完整的异常栈(你提供的日志是截断的),找到最底层的异常原因,明确是哪个环节触发了循环。
5. 检查JBoss EAP的部署模式差异
本地和其他实例的JBoss EAP可能运行在不同模式(比如standalone vs domain),或者有不同的安全、数据源配置:
- 确认其他实例的配置和本地是否一致,特别是和Web服务安全相关的配置(因为你用到了WSS4J拦截器)。
内容的提问来源于stack exchange,提问作者Ravi
相关产品推荐
相关产品推荐

