You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

保留camel-core 2.13.4升级camel-saxon至3.14.0可行吗?及报错求助

问题解决方案

1. 单独升级camel-saxon的兼容性问题

你遇到的NoSuchMethodError本质是camel-saxon 3.14.0与camel-core 2.13.4跨大版本不兼容:

  • Camel组件(如camel-saxon)与核心框架(camel-core)深度绑定,2.x到3.x属于重大版本迭代,API结构有突破性变更。
  • 3.14.0的camel-saxon调用了org.apache.camel.language.xquery.XQueryLanguage类的property方法,而该方法在2.13.4版本的camel-core中不存在,导致反射调用失败。

不存在官方桥接API/JAR能解决这种跨大版本的兼容性问题,必须保证camel-saxon与camel-core版本完全匹配。如果要升级camel-saxon到3.x,就必须同步升级camel-core到同版本(3.14.0)。

2. 升级camel-core到3.14.0后的XSLT端点错误

这个错误源于Camel 3.x对组件参数的bean引用规则调整:

  • Camel 2.x中,xslt组件的transformerFactory参数可直接填写bean id;但3.x版本要求必须用#bean:beanId格式明确声明引用Spring bean。

修改路由配置中的xslt端点URI即可解决:

<inOut uri="xslt:path/to/file/myfile.xsl?transformerFactory=#bean:tFactory"/>

完整修改后的路由代码片段:

<bean id="tFactory" class="net.sf.saxon.TransformerFactoryImpl"/>
<camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
<route>
        <from uri="vm:urn:myurn" />
        <convertBodyTo type="java.lang.String"/>
        <log message="my message" loggingLevel="INFO"
            logName="my.logname" />
        <inOut uri="xslt:path/to/file/myfile.xsl?transformerFactory=#bean:tFactory"/>
        <convertBodyTo type="java.lang.String"/>
        <log message="my message" loggingLevel="INFO"
                logName="my.log" />
        <inOut uri="mock:processedout"/>
    </route>
</camelContext>

修改后重新执行mvn clean install即可解决端点解析失败问题。

内容的提问来源于stack exchange,提问作者greenTea

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 07:10:32