when I run the marshal operation I get the following error:
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation]
...
Caused by: com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:237)
at com.sun.xml.internal.bind.v2.runtime.LeafBeanInfoImpl.serializeRoot(LeafBeanInfoImpl.java:126)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:483)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308)
... 6 more
This is my function for Marshalling...
public StringBuffer Marshaller(Object marshall){ // make marshalling->Java to XML
StringWriter writer = new StringWriter();
try {
JAXBContext jaxbContext=JAXBContext.newInstance(marshall.getClass());
Marshaller jaxbMarshaller=jaxbContext.createMarshaller();
// çıktı
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(marshall, writer);
System.out.println(writer.getBuffer().toString());
} catch (PropertyException e) {
e.printStackTrace();
} catch (JAXBException e) {
e.printStackTrace();
}
return writer.getBuffer();
}
Thanks for your interests..