2 count of Illegal Annotation Exception
来源:互联网 发布:钻石展位 淘宝首页 编辑:程序博客网 时间:2024/06/05 11:17
2 count of Illegal Annotation Exception
I have a Customer and CustomerFullAddress class and i am using JAXB to try to produce an XML file
<Customer CustomerID="GREAL"> <CompanyName>Great Lakes Food Market</CompanyName> <ContactName>Howard Snyder</ContactName> <ContactTitle>Marketing Manager</ContactTitle> <Phone>(503) 555-7555</Phone> <FullAddress> <Address>2732 Baker Blvd.</Address> <City>Eugene</City> <Region>OR</Region> <PostalCode>97403</PostalCode> <Country>USA</Country> </FullAddress></Customer>
The Customer Class looks like below (Its not a full implementation)
package org.abc.customers;import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlRootElement;import javax.xml.bind.annotation.XmlType;@XmlRootElement(name = "customer")@XmlType (propOrder = { "companyName", "contactName", "contactTitle", "phone" })public class Customer {*@XmlElement(name = "customerfulladdress")private CustomerFullAddress custAdd;*private String companyName;private String contactName;private String contactTitle;private int phone;public CustomerFullAddress getCustAddress() {return custAdd;}public void setCustAddress(CustomerFullAddress custAdd) {this.custAdd = custAdd;}...
While the CustomerFullAddress is
package org.abc.customers;import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlRootElement;import javax.xml.bind.annotation.XmlType;@XmlRootElement(name = "customerfulladdress")//If you want you can define the order in which the fields are written//Optional@XmlType(propOrder = { "address", "city", "region", "postalCode", "country" })public class CustomerFullAddress {private String address;...public String getAddress() { return address;}public void setAddress(String address) { this.address = address;}..... }
and the error is
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions Property custAdd is present but not specified in @XmlType.propOrder this problem is related to the following location: at private org.abc.customers.CustomerFullAddress org.abc.customers.Customer.custAdd at org.abc.customers.Customer Property custAddress is present but not specified in @XmlType.propOrder this problem is related to the following location: at public org.abc.customers.CustomerFullAddress org.abc.customers.Customer.getCustAddress() at org.abc.customers.Customer
Thanks for having a look!
1 Answer
From the JavaDoc for @XmlType:
propOrder
All of the JavaBean properties being mapped to XML Schema elements must be listed.
You need to add the CustomerFullAddress
property to the propOrder
for Customer
.
- 2 count of Illegal Annotation Exception
- Invocation of init method failed; nested exception is org.hibernate.PropertyAccessException: Illegal
- mediaMetadataRetriever.setDataSource throws illegal argument exception
- ClassPathXmlApplicationContext出现illegal Arument Exception异常
- count the number of 2s
- Illegal redeclaration of module <glbl>.&Element index 2 into memp is out of bounds
- Summary of Annotation
- use count of shared_ptr
- Count of Range Sum
- Exception in thread "main" java.lang.illegalArgumentException : illegal component position
- ORA-00997: illegal use of LONG datatype
- java.sql.SQLException: Illegal mix of collations
- ORA-00997: illegal use of LONG datatype
- mysql “Illegal mix of collations”出错解决办法
- 编码不一致问题-Illegal mix of collations
- mysql:Illegal mix of collations错误
- Why are arrays of references illegal?
- Illegal mix of collations for operation 'like'
- lua 自学笔记5
- 第十周小学生算题四则运算
- CryptoDev for OpenSSL example
- 有关Dagger的Scope
- react初学者福利来了:react+redux实现一个列表的静态应用
- 2 count of Illegal Annotation Exception
- BZOJ 2140 稳定婚姻
- [51nod 1149]Pi的递推式
- CryptoDev usage demo
- UVa 11440 Help Tomisu
- printf输出字符串的一些格式
- Linux系统中的日志管理
- 2、adb常用命令
- label标记关键字