Tuesday, 4 December 2012

JAXB : IllegalAnnotationExceptions - Class has two properties of the same name

just developing a test jaxb application and wanted to let getters and setters be created automatically with Lombok.
As I was attempting to assign annotations of private field members, got this exception:


Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Class has two properties of the same name "name"
this problem is related to the following location:
at public java.lang.String de.domain.jaxbtest.model.Book.getName()
at de.domain.jaxbtest.model.Book
at private java.util.List de.domain.jaxbtest.model.Bookstore.bookList
at de.domain.jaxbtest.model.Bookstore

the solution was easy as just adding @XmlAccessorType(XmlAccessType.FIELD) to defined class: