开发者

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

开发者 https://www.devze.com 2023-03-03 19:28 出处:网络
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 W

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 count开发者_开发问答s 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?


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).


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消