如何处理com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:7个IllegalAnnotationExceptions计数

时间:2018-09-03 06:16:58

标签: xml web-services soap xsd jaxb

我已经创建了一个基于Maven的SOAP API项目,但是当我试图在tomcat服务器上运行该项目时出现异常。

Exception Details

据我了解,我在XSD中观察到了一些东西。 XSD具有1个命名空间 dtv ,并且如果主XSD中存在任何引用并且其类型为String,并且在<xs:choice maxOccurs="unbounded">标记下使用,则会导致此问题。 以下是XSD的代码段

<xs:element name="Layaway">
<xs:complexType>
  <xs:sequence>
    <xs:choice maxOccurs="unbounded">
      <xs:element ref="ixretail:AccountNumber"/>
      <xs:element ref="ixretail:ItemID"/>
      <xs:element ref="ixretail:Description"/>
      <xs:element ref="ixretail:RegularSalesUnitPrice"/>
      <xs:element ref="ixretail:ActualSalesUnitPrice"/>
      <xs:element ref="ixretail:ExtendedAmount"/>
      <xs:element ref="ixretail:Quantity"/>
      <xs:element ref="dtv:OrderType"/>
      <xs:element ref="ixretail:MerchandiseHierarchy"/>
      <xs:element ref="ixretail:Associate"/>
      <xs:element ref="dtv:PercentageOfItem"/>
      <xs:element ref="ixretail:RetailPriceModifier"/>
      <xs:element ref="ixretail:Tax"/>
      <xs:element ref="ixretail:GiftReceiptFlag"/>
    </xs:choice>
  </xs:sequence>
  <xs:attribute name="ItemType" use="required" type="xs:NCName"/>
  <xs:attribute ref="dtv:Status" use="required"/>
</xs:complexType>

,命名空间变量的定义为

<xs:element name="OrderType" type="xs:NCName"/>

ObjectFactory类的代码段

private final static QName _OrderType_QNAME = new QName("http://www.datavantagecorp.com/xstore/", "OrderType");

 @XmlElementDecl(namespace = "http://www.datavantagecorp.com/xstore/", name = "OrderType")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public JAXBElement<String> createOrderType(String value) {
    return new JAXBElement<String>(_OrderType_QNAME, String.class, null, value);

}

下面是Layaway类代码段

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"accountNumberOrItemIDOrDescription"})
@XmlRootElement(name = "Layaway")
public class Layaway {
@XmlElementRefs({
    @XmlElementRef(name = "Associate", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = Associate.class),
    @XmlElementRef(name = "Description", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "ActualSalesUnitPrice", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "RetailPriceModifier", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = RetailPriceModifier.class),
    @XmlElementRef(name = "Tax", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = Tax.class),
    @XmlElementRef(name = "PercentageOfItem", namespace = "http://www.datavantagecorp.com/xstore/", type = PercentageOfItem.class),
    @XmlElementRef(name = "MerchandiseHierarchy", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = MerchandiseHierarchy.class),
    @XmlElementRef(name = "RegularSalesUnitPrice", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "GiftReceiptFlag", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "ItemID", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "OrderType", namespace = "http://www.datavantagecorp.com/xstore/", type = JAXBElement.class),
    @XmlElementRef(name = "Quantity", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "ExtendedAmount", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class),
    @XmlElementRef(name = "AccountNumber", namespace = "http://www.nrf-arts.org/IXRetail/namespace/", type = JAXBElement.class)
})
protected List<Object> accountNumberOrItemIDOrDescription;
public List<Object> getAccountNumberOrItemIDOrDescription() {
    if (accountNumberOrItemIDOrDescription == null) {
        accountNumberOrItemIDOrDescription = new ArrayList<Object>();
    }
    return this.accountNumberOrItemIDOrDescription;
}

如果需要进一步的信息,请发表评论。我尝试了StackOverflow提供的许多解决方案,但对我没有任何帮助。

请帮助解决此问题。

0 个答案:

没有答案