• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Issue in Marshalling

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Hug your destiny! And hug this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic