java - JAXB,CXF : There's no ObjectFactory with an @XmlElementDecl for the element . ..与

标签 java wsdl jaxb cxf

我正在使用 JAXB 和 CXF 创建 WSDL 优先网络服务。我不拥有 WSDL,因此无法对其进行更改。我正在使用 ftp://ftp.ihe.net/TF_Implementation_Material/ITI/wsdl/PIXManager.wsdl作为我的 WSDL。我使用 CXF 2.3.0 生成 Java 类。

Java 类生成很顺利,但是当我试图在 Web 应用程序中运行它时,出现错误

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 17 counts of IllegalAnnotationExceptions

17个计数的格式

There's no ObjectFactory with an @XmlElementDecl for the element {urn:hl7-org:v3}assignedDevice.
        this problem is related to the following location:
            at protected javax.xml.bind.JAXBElement org.hl7.v3.QUQIMT021001UV01AuthorOrPerformer.assignedDevice

当我转到提到的类,即 QUQIMT021001UV01AuthorOrPerformer 并查看 assignedDevice 字段时,我看到了这个

@XmlElementRef(name = "assignedDevice", namespace = "urn:hl7-org:v3", type = JAXBElement.class)
protected JAXBElement<COCTMT090300UV01AssignedDevice> assignedDevice;

当我查看包的 ObjectFactory 时,我看到了这个

private final static QName _COCTMT090303UV01AssignedDeviceAssignedDevice_QNAME = new QName("urn:hl7-org:v3", "assignedDevice");

我的 17 个错误都是相似的。为了让我的服务正常工作,我在代码生成或运行时可以做什么?

最佳答案

您在运行时使用的 Java 版本是什么?在使用 Java 6 运行时,我遇到了与 OTA 架构类似的问题。我通过对 Maven 配置进行以下更改来消除该问题:

  1. 提供的范围内使用 JAXB impl 2.1.*(而不是 2.2),以匹配 Java 6 中包含的 JAXB 版本。
  2. 使用 JAX-WS 2.1(而不是 2.2)来匹配 Java 6 和 JAXB 2.1.x。
  3. 将选项 frontEnd 添加到 Maven cxf-codegen-plugin 插件并将其设置为 jaxws21(或者如果使用 wsdl2java 在命令行上,使用“-fe jaxws21”选项。

关于java - JAXB,CXF : There's no ObjectFactory with an @XmlElementDecl for the element . ..与,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5939715/

相关文章:

java - 让 MOXy @XmlPath 使用命名空间

java - Elastic Search - 通过字段的起始字符获取记录

java - 考虑在配置中定义一个名为 'entityManagerFactory' 的 bean - Spring boot

java - Android - MediaPlayer 崩溃

android - 从 WSDL 中查找 SOAPAction

java - 为 xsd :any element while importing WSDL using wsimport 提供架构

java - Apache http 客户端 : request does not get redirected

JavaME MIDlet 不会清除变量吗?

spring - 在 Spring 生成的 WSDL 中指定操作顺序

java - 用于不带命名空间的子树的 XmlstreamWriter 和 Jaxb