JAXB、CXF:没有带有 @XmlElementDecl 元素的 ObjectFactory ...
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在运行时使用什么 Java 版本?使用 Java 6 运行时,我遇到了 OTA 模式的类似问题。我通过对 Maven 配置进行以下更改消除了该问题:
provided
范围,以匹配 Java 6 中包含的 JAXB 版本。frontEnd
添加到 Mavencxf-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:
provided
scope, to match JAXB version included in Java 6.frontEnd
to the Mavencxf-codegen-plugin
plug-in and set it tojaxws21
(or if usingwsdl2java
on command line, use "-fe jaxws21
" option).生成类时,还会生成一个名为 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
我遇到了这个类似的错误,原因是 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