• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB annotation error

 
Ranadhir Nag
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to add the following annotation to the object tree created through xjc.

@XmlRootElement
public abstract class Customer {

// ======================================
// = Attributes =
// ======================================
@XmlAttribute
protected Long id;
protected String telephone;
protected String email;
protected Address homeAddress;
@XmlElementWrapper(name = "delivery")
@XmlElement(name = "address")
protected List<Address> deliveryAddresses = new ArrayList<Address>();

// ======================================
// = Getters & Setters =
// ======================================
public Long getId() {
return id;
}
........................
........................


I get a annotation error in compilation:

=====================================================================com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnn
tationExceptions
Class has two properties of the same name "deliveryAddresses"
this problem is related to the following location:
at public java.util.List customer.Customer.getDeliveryAddresses
)
at customer.Customer
this problem is related to the following location:
at protected java.util.List customer.Customer.deliveryAddresses
at customer.Customer
Class has two properties of the same name "id"
this problem is related to the following location:
at public java.lang.Long customer.Customer.getId()
at customer.Customer
this problem is related to the following location:
at protected java.lang.Long customer.Customer.id
at customer.Customer

===========================

What is the mistake I am committing?
I am using JAXB 2.0
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic