Problem1: There is no grammar information generated in wadl
Cause:
org.apache.cxf.jaxrs.model.wadl.WadlGeneratorrelies on org.apache.cxf.jaxrs.utils.ResourceUtils
to create a JAXBContext, without a JAXBContext, no grammar section will be generated
JAXB is not printing stack trace for any problem
LOG.fine("No JAXB context can becreated");
Error pattern | Cause | Example | Solution |
Two classes have the same XML type name "xxx". Use @XmlType.name and @XmlType.namespace to assign different names to them. | Two properties are with the same class name, but the classes are of different type | In class CustomerContactsRequest @XmlElement(name = "name") private ContactName name; The ContactName is an inner static class of CustomerContactsRequest
In class CustomerContactsV2Request @XmlElement(name = "name") private ContactName name; The ContactName is an inner static class of CustomerContactsV2Request | Use @XmlType.name and @XmlType.namespace to differentiate the 2 inner classes |
Xxx is a non-static inner class, and JAXB can‘t handle those. | Use an inner class that is non-static | In class UpdateCustomerPaymentInstrumentDetails There is an inner class public class UpdateCreditCardDetails that is non-static | Make the class a static inner class |
Problem2: Generated grammar is not associated with resource method‘s request andresponse
Cause:
We need a namespace, without namespace, it cannot associate request response with xsd types declared in the grammar section
See org.apache.cxf.jaxrs.model.wadl.WadlGenerator.generateQName
There are two ways of declare a namespace:
XmlRootElement(namespace=xxx) at class level
XmlSchema (namespace=xxx) at packagelevel
CXF WADL generation,布布扣,bubuko.com
原文地址:http://shadowisper.blog.51cto.com/3189863/1433028