• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in Marshalling  RSS feed

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to marshall Object with class structure mentioned below :

@XmlRootElement
public class WrapperObject {

private Order order;

public Order getOrder() {
return order;
}

public void setOrder(Order order) {
this.order = order;
}

public WrapperObject () {

}
public WrapperObject (Order order){
this.order = order;
}

public static void main(String[] args) {
try {
//marshalling code
JAXBContext context = JAXBContext.newInstance(WrapperObject.class);
Marshaller m = context.createMarshaller();

m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(new WrapperObject(new Order()),System.out);

} catch (Exception e) {
e.printStackTrace();
}
}
}

public class Order implements Cloneable {

private OrderLinesType orderLines;
public OrderLinesType getOrderLines() {
return orderLines;
}
public void setOrderLines(OrderLinesType orderLines) {
this.orderLines = orderLines;
}

}

public class OrderLinesType implements Serializable{

private OrderLine[] orderLine;
//getter setter
}

public class OrderLine implements Serializable{

private byte[] attachmentNP;
//getter and setter
}

On running this code following exception is coming

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Class has two properties of the same name "attachmentNP"
this problem is related to the following location:
at public byte[] dk.tdc.kvikoc.core.model.OrderLine.getAttachmentNP()
at dk.tdc.kvikoc.core.model.OrderLine
at public dk.tdc.kvikoc.core.model.OrderLine[] dk.tdc.kvikoc.core.model.OrderLinesType.getOrderLine()
at dk.tdc.kvikoc.core.model.OrderLinesType
at public dk.tdc.kvikoc.core.model.OrderLinesType dk.tdc.kvikoc.core.model.Order.getOrderLines()
at dk.tdc.kvikoc.core.model.Order
at public dk.tdc.kvikoc.core.model.Order dk.tdc.kvikoc.app.pdf.WrapperObject.getOrder()
at dk.tdc.kvikoc.app.pdf.WrapperObject
this problem is related to the following location:
at public byte[] dk.tdc.kvikoc.core.model.OrderLine.attachmentNP
at dk.tdc.kvikoc.core.model.OrderLine
at public dk.tdc.kvikoc.core.model.OrderLine[] dk.tdc.kvikoc.core.model.OrderLinesType.getOrderLine()
at dk.tdc.kvikoc.core.model.OrderLinesType
at public dk.tdc.kvikoc.core.model.OrderLinesType dk.tdc.kvikoc.core.model.Order.getOrderLines()
at dk.tdc.kvikoc.core.model.Order
at public dk.tdc.kvikoc.core.model.Order dk.tdc.kvikoc.app.pdf.WrapperObject.getOrder()
at dk.tdc.kvikoc.app.pdf.WrapperObject


Please help me out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!