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:
- Use JAXB impl 2.1.* (instead of 2.2) with
provided
scope, to match JAXB version included in Java 6. - Use JAX-WS 2.1 (instead of 2.2) to match Java 6 and JAXB 2.1.x.
- Add the option
frontEnd
to the Mavencxf-codegen-plugin
plug-in and set it tojaxws21
(or if usingwsdl2java
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
精彩评论