将Saxon-PE与Apache Camel一起使用时,错误预加载Saxon类 [英] Using Saxon-PE with Apache Camel, Error Pre-Loading Saxon Classes

查看:60
本文介绍了将Saxon-PE与Apache Camel一起使用时,错误预加载Saxon类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近获得了Saxon-PE的试用许可证,并希望在Camel中使用此版本的Saxon.我下载了Saxon-PE-9.6.0.8罐子,并通过maven将其包含在我的项目中.我正在使用骆驼2.16.0. 我已经尝试了许多方法,但是通过使用Camel的?transformerFactory = ..."选项并将其传递给了Saxon的ProfessionalTransformerFactoryImpl(在我的Spring配置中注册为bean),我取得了最大的进步.

I have recently obtained a trial license for Saxon-PE and wish to use this version of Saxon within Camel. I downloaded the Saxon-PE-9.6.0.8 jars and have included them into my project via maven. I am using Camel 2.16.0. I have tried many approaches to this, but I have made the most headway by using Camel's "?transformerFactory=..." option and passing it Saxon's ProfessionalTransformerFactoryImpl, which is registered as a bean in my Spring config.

启动我的应用程序时,使用xslt转换的路由初始化失败,并显示以下堆栈跟踪:

When starting my application, the route initialization with the xslt transformation fails with the following stack trace:

由以下原因引起:java.lang.IllegalStateException:预加载Saxon时出错 类.确保类路径上有撒克逊语,并且 classloader可以加载以下两个类: net.sf.saxon.event.Receiver,net.sf.saxon.serialize.MessageWarner.在 org.apache.camel.builder.xml.XsltBuilder.doStart(XsltBuilder.java:618) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.component.xslt.XsltEndpoint.doStart(XsltEndpoint.java:396) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3219) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1209) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1170) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1166) 〜[camel-core-2.16.0.jar:2.16.0]在 org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:583) 〜[camel-core-2.16.0.jar:2.16.0] ...省略了38个常见框架 创建人:java.lang.NoSuchMethodException: net.sf.saxon.jaxp.TransformerImpl.setMessageEmitter(net.sf.saxon.event.Receiver) 在java.lang.Class.getMethod(Class.java:1786)〜[na:1.8.0_45]在 org.apache.camel.builder.xml.XsltBuilder.doStart(XsltBuilder.java:616) 〜[camel-core-2.16.0.jar:2.16.0] ...省略了47个常见框架

Caused by: java.lang.IllegalStateException: Error pre-loading Saxon classes. Make sure you have saxon on the classpath, and the classloader can load the following two classes: net.sf.saxon.event.Receiver, net.sf.saxon.serialize.MessageWarner. at org.apache.camel.builder.xml.XsltBuilder.doStart(XsltBuilder.java:618) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.component.xslt.XsltEndpoint.doStart(XsltEndpoint.java:396) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3219) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1209) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1170) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1166) ~[camel-core-2.16.0.jar:2.16.0] at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:583) ~[camel-core-2.16.0.jar:2.16.0] ... 38 common frames omitted Caused by: java.lang.NoSuchMethodException: net.sf.saxon.jaxp.TransformerImpl.setMessageEmitter(net.sf.saxon.event.Receiver) at java.lang.Class.getMethod(Class.java:1786) ~[na:1.8.0_45] at org.apache.camel.builder.xml.XsltBuilder.doStart(XsltBuilder.java:616) ~[camel-core-2.16.0.jar:2.16.0] ... 47 common frames omitted

问题是JAXP TransformerImpl中不存在setMessageEmitter()方法.

The issue is that the setMessageEmitter() method does not exist in the JAXP TransformerImpl.

如果有人对将Saxon-PE/EE与骆驼集成有任何经验,我将不胜感激.我需要Saxon-PE以便利用xsl样式表中的外部函数调用.以前,在同一项目中,我使用Saxon-HE(通过camel-saxon maven依赖项)没有任何麻烦.仅在切换到Saxon-PE时才会出现此问题.

If anybody has any experience integrating Saxon-PE/EE with camel, I would appreciate any input. I need Saxon-PE in order to make use of external function calls from my xsl stylesheets. Previously, in the same project, I have used with Saxon-HE (via the camel-saxon maven dependency) without any trouble. It is only upon switching to Saxon-PE that this problem occurs.

我可以提供其他可能有帮助的详细信息. 预先感谢.

I can provide any other details that might help. Thanks in advance.

推荐答案

Saxon基本上具有三层接口.第1层是公共API,包括JAXP和XQJ接口以及s9api接口.我们努力使这些版本之间保持兼容.第2层是系统编程接口"-有点低级,但是集成人员经常需要-例如NodeInfo和Receiver接口. Saxon主要版本之间的SPI通常会有一些小的变化(例如9.5到9.6,或9.6到9.7).对于维护版本(例如9.5.0.7至9.5.0.8),我们非常努力地避免任何不兼容的更改.即使在主要发行版中,我们也尽量避免对SPI进行不必要的更改,但如果在体系结构上必要,我们将进行更改.例如,直到9.6,我们在Receiver界面中将位置信息(系统ID,行和列号)公开为全局唯一整数.但是,在XSLT 3.0中以及因此在Saxon 9.7中引入了单独编译的软件包,这意味着该设计变得不可行,因此我们改用传递Location对象.尽管这些更改很小,但足以确保使用Saxon且在稳定的公共API之外出现问题的应用程序通常至少需要重新编译才能使用新的Saxon版本.

Saxon basically has three tiers of interfaces. Tier 1 is public APIs, including the JAXP and XQJ interfaces and the s9api interface. We try very hard to keep these compatible across releases. Tier 2 is "system programming interfaces" - things that are a little lower-level, but which are frequently needed by integrators - examples are the NodeInfo and Receiver interfaces. There are usually a few small changes to SPIs between Saxon major releases (e.g. 9.5 to 9.6, or 9.6 to 9.7). With maintenance releases (e.g. 9.5.0.7 to 9.5.0.8) we try very hard to avoid any incompatible changes. We try to avoid gratuitous changes to SPIs even at major releases, but we will make a change if it is architecturally necessary. For example, until 9.6 we exposed location information (system id, line and column number) in the Receiver interface as a globally unique integer. But the introduction of separately-compiled packages in XSLT 3.0, and hence in Saxon 9.7, meant that this design became unworkable, so we switched to passing a Location object instead. Although these changes are minor, they are enough to ensure that an application that uses Saxon, and strays outside the stable public APIs, typically needs to at least be recompiled to work with a new Saxon version.

第三层由内部API组成:一个示例是由编译器构建的表达式树的结构.尽管某些第三方应用程序(例如调试器或性能分析器)可能需要访问此类接口,但我们并未尝试保持它们从一个主要版本到下一个主要版本的兼容性.

The third tier consists of internal APIs: an example is the structure of the expression tree built by the compiler. Although some third party applications (e.g. debuggers or performance profilers) may need to access such interfaces, we make no attempt to keep them compatible from one major release to the next.

我认为影响骆驼的9.5和9.6之间的特定变化可能是由于内部Controller类不再充当JAXP Transformer接口的实现类的事实(因此将Transformer强制转换为Controller不再起作用).多年来,当控制器同时执行各种其他功能时,保持其角色的问题已经逐渐增加.同时,JAXP转换接口(牢固地基于XSLT 1.0)对于Saxon所做的新事物越来越陌生,并且已经到了防止它成为我们内部设计约束的时候了.

I think the particular change between 9.5 and 9.6 that affects Camel is probably due to the fact that the internal Controller class no longer serves as the implementation class of the JAXP Transformer interface (so casting Transformer to Controller no longer works). The problems of maintaining the Controller in this role, when it also performed various other functions, had slowly increased over the years; at the same time the JAXP transformation interface (which is firmly based on XSLT 1.0) is increasingly peripheral to the new things Saxon is doing and the time had come to prevent it acting as a constraint on our internal design.

我一直认为,我们必须权衡使用户易于前进的需求和防止代码库中的结构衰减(以及由此带来的不可靠性)的需求.随着产品的成熟,稳定性变得越来越重要,但是流和模块化编译之类的新功能在架构上具有破坏性,我们不希望停滞不前.

I have always taken the view that we have to balance the need to make it easy for users to move forward and the need to prevent structural decay (and hence unreliability) in the code base. As the product has matured, stability has become increasingly important, but new facilities like streaming and modular compilation are architecturally disruptive, and we don't want to stand still.

我们始终准备向确实有困难的用户提供旧版本.

We are always prepared to make old releases available to users who have genuine difficulties moving forward.

这篇关于将Saxon-PE与Apache Camel一起使用时,错误预加载Saxon类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆