JAXB、CXF:没有带有 @XmlElementDecl 元素的 ObjectFactory ...

发布于 2024-11-05 15:46:22 字数 1288 浏览 5 评论 0原文

我正在使用 JAXB 和 CXF 创建第一个 WSDL Web 服务。我不拥有 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

The 17 counts are of the format

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)并查看字段分配设备时,我看到 我

@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 个错误都是类似的。在代码生成或运行时我可以做什么才能让我的服务正常工作?

I'm creating a WSDL first webservice with JAXB and CXF. I do not own the WSDL, so I cannot make changes to it. I'm using ftp://ftp.ihe.net/TF_Implementation_Material/ITI/wsdl/PIXManager.wsdl as my WSDL. I used CXF 2.3.0 to generate Java classes.

Java class generation went fine, but when I'm trying to run this in a web application, I get an error

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

The 17 counts are of the format

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

When I go to the class mentioned, i.e. QUQIMT021001UV01AuthorOrPerformer and look at the field assignedDevice, I see this

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

When I look at the ObjectFactory of the package, I see this

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

All my 17 errors are similar. What can I do during my codegen or runtime in order to get my service work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷路的信 2024-11-12 15:46:22

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

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

What Java version are you using at run-time? I had a similar issue with OTA schema when running with Java 6. I eliminated the problem by making the following changes to the Maven configuration:

  1. Use JAXB impl 2.1.* (instead of 2.2) with provided scope, to match JAXB version included in Java 6.
  2. Use JAX-WS 2.1 (instead of 2.2) to match Java 6 and JAXB 2.1.x.
  3. Add the option frontEnd to the Maven cxf-codegen-plugin plug-in and set it to jaxws21 (or if using wsdl2java on command line, use "-fe jaxws21" option).
吝吻 2024-11-12 15:46:22

生成类时,还会生成一个名为 jaxb.properties 的文件。确保应用程序在运行时可以访问该文件。
我遇到了同样的问题,这是由于 maven 打包造成的:maven 不会包含在 src/main/java 树下面的包资源文件(如 jaxb.properties)中,除非特别指示这样做。我使用 org.codehaus.mojo:build-helper-maven-plugin 和添加资源目标来完成此操作。
希望这有帮助

When you generate the classes, you also generate a file called jaxb.properties. Make sure this file is accessible to the application at runtime.
I had the same problem and it was due to maven packaging: maven will not include in the package resource files (like jaxb.properties) that are below the src/main/java tree unless specifically instructed to do so. I did this using the org.codehaus.mojo:build-helper-maven-plugin with the add-resource goal.
Hope this helps

も让我眼熟你 2024-11-12 15:46:22

我遇到了这个类似的错误,原因是 Web 服务生成的存根 Java 类之间存在冲突。

如果上述答案不起作用,请尝试查找冲突。

一次添加一个存根并逐步添加。

希望有帮助

I Faced this similar error and the reason was having conflicts between the webservices generated stub java classes.

if above answers does not work , try look for conflicts.

add one stub at a time and add incrementally.

hope it helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文