我创建了一个简单的 Camel 路由,带有一个转换器 bean,它使用 HAPI 库将 HL7 消息转换为 XML。该路线在使用“mvn camel:run”运行时有效。当我将(作为 OSGi 包)部署到 ServiceMix 时,当尝试将消息解析为 XML 时,路由会在运行时引发异常:
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.xerces.parsers.DOMParser.<init>(Lorg/apache/xerces/xni/parser/XMLParserConfiguration;)V" the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) of the current class, ca/uhn/hl7v2/parser/XMLParser, and the class loader (instance of <bootloader>) for resolved class, org/apache/xerces/parsers/DOMParser, have different Class objects for the type org/apache/xerces/xni/parser/XMLParserConfiguration used in the signature
at ca.uhn.hl7v2.parser.XMLParser.<init>(XMLParser.java:108)[194:ca.uhn.hapi.osgi-base:1.2]
at ca.uhn.hl7v2.parser.XMLParser.<init>(XMLParser.java:99)[194:ca.uhn.hapi.osgi-base:1.2]
at ca.uhn.hl7v2.parser.DefaultXMLParser.<init>(DefaultXMLParser.java:77)[194:ca.uhn.hapi.osgi-base:1.2]
at simple.messaging.app.SimpleTransformer.transform(SimpleTransformer.java:26)[223:SimpleMessagingApp2:0.0.1.SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_29]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_29]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_29]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_29]
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:329)[89:org.apache.camel.camel-core:2.8.0.fuse-06-11]
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:231)[89:org.apache.camel.camel-core:2.8.0.fuse-06-11]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:171)[89:org.apache.camel.camel-core:2.8.0.fuse-06-11]
... 43 more
我正在使用安装了 Camel-HL7 功能的 ServiceMix 4.4.2。JDK 1.6u29。用于构建捆绑包的 Apache Felix maven 插件。
SimpleTransformer.java 的第 26 行:
XMLParser xmlParser = new DefaultXMLParser();
XMLParser/DefaultXMLParser 是从 hapi-osgi-base 包中导入的,该包似乎在安装 Camel-HL7 功能时自动部署。hapi-osgi-base 包嵌入了 xercesImpl-2.4.0.jar。