gpt4 book ai didi

java - 在 Axis 服务上使用 Hapi : "Can' t create XML document"

转载 作者:行者123 更新时间:2023-11-28 22:42:39 24 4
gpt4 key购买 nike

我正在开发一个 Axis 服务来连接 HL7 远程服务。我有一个类 (Hl7MessageTranslator) 来编码这样的查询请求:

public Hl7MessageTranslator(...)
{
...
parser = new DefaultXMLParser();
}

public String encodeRequest(...) throws ... HL7Exception
{
// prepare HL7 query request
QRY_A19 qryA19 = new QRY_A19();
...
return parser.encode(qryA19);
}

encodeRequest() 方法在 tomcat 环境(JUnit 测试)外部调用时工作正常,但在从 Axis 服务调用时失败:我在创建类(class)时收到以下警告:

SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also  http://www.slf4j.org/codes.html#log4j_version
INFO - 2014-05-20 09:11:07,543 - Classe: ca.uhn.hl7v2.util.Home - Metodo: setHomeDirectory - Descrizione: hapi.home is set to C:\Programmi\eclipse-j2ee-helios\.
INFO - 2014-05-20 09:11:07,933 - Classe: ca.uhn.hl7v2.VersionLogger - Metodo: printHapiVersion - Descrizione: HAPI version is: 2.2
INFO - 2014-05-20 09:11:07,949 - Classe: ca.uhn.hl7v2.VersionLogger - Metodo: checkStructureLibraries - Descrizione: Default Structure libraries found for HL7 versions 2.5, 2.6,
WARN - 2014-05-20 09:11:08,011 - Classe: ca.uhn.hl7v2.VersionLogger - Metodo: checkDOMImplementation - Descrizione: Error occured while trying to retrieve a DOMImplementation.
java.lang.RuntimeException: java.lang.ClassCastException: org.apache.xerces.dom.DOMXSImplementationSourceImpl cannot be cast to org.w3c.dom.DOMImplementationSource
at ca.uhn.hl7v2.util.XMLUtils.getDOMImpl(XMLUtils.java:55)
at ca.uhn.hl7v2.VersionLogger.checkDOMImplementation(VersionLogger.java:44)
at ca.uhn.hl7v2.VersionLogger.init(VersionLogger.java:36)
at ca.uhn.hl7v2.DefaultHapiContext.<init>(DefaultHapiContext.java:126)
at ca.uhn.hl7v2.DefaultHapiContext.<init>(DefaultHapiContext.java:112)
at ca.uhn.hl7v2.DefaultHapiContext.<init>(DefaultHapiContext.java:103)
at ca.uhn.hl7v2.parser.Parser.<init>(Parser.java:71)
at ca.uhn.hl7v2.parser.XMLParser.<init>(XMLParser.java:89)
at ca.uhn.hl7v2.parser.DefaultXMLParser.<init>(DefaultXMLParser.java:81)
at com.avelco.integrazioni.areavasta.naar.Hl7MessageTranslator.<init>(Hl7MessageTranslator.java:105)
at com.avelco.integrazioni.areavasta.naar.NaarBridge.requestGrid(NaarBridge.java:135)
at com.avelco.integration.services.Service.requestGrid(Service.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
...
WARN - 2014-05-20 09:11:08,011 - Classe: ca.uhn.hl7v2.VersionLogger - Metodo: checkDOMImplementation - Descrizione: XML parsing and encoding as well as working with Conformance Profiles will fail.

调用 parser.encode() 方法时出现以下错误:

20/05/2014 09:11:08 : debug: Filling MSH ...
20/05/2014 09:11:08 : debug: Filling QRD ...
20/05/2014 09:11:08 : debug: Filling QRF ...
ca.uhn.hl7v2.HL7Exception: Can't create XML document - java.lang.RuntimeException
at ca.uhn.hl7v2.parser.DefaultXMLParser.encodeDocument(DefaultXMLParser.java:115)
at ca.uhn.hl7v2.parser.XMLParser.doEncode(XMLParser.java:241)
at ca.uhn.hl7v2.parser.Parser.encode(Parser.java:276)
at com.avelco.integrazioni.areavasta.naar.Hl7MessageTranslator.encodeRequest(Hl7MessageTranslator.java:174)
at com.avelco.integrazioni.areavasta.naar.NaarBridge.requestGrid(NaarBridge.java:144)
at com.avelco.integration.services.Service.requestGrid(Service.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

因为它在被 JUnit 调用时有效,所以它一定是一个依赖项/配置问题,但我不知道在哪里寻找它。

提前致谢

马西莫

最佳答案

是 Axis 依赖的jar冲突问题。如果您有任何单独的 log4j jar,请将其删除。

关于java - 在 Axis 服务上使用 Hapi : "Can' t create XML document",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23753966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com