In my webservice (using RestEasy) project I have a dependency to a jar. I use from that jar a java class : Person.
My problem is that I need to serialize a Person instance to XML, But I get the following error :
unable to marshal type "entities.Person" as an element because it is missing an @XmlRootElement annotation
However, I cannot change the Person class to add the annotation @XmlRootElement (it is a third party jar).
Is there any other way (methods, libraries, ... ) to marshal a Person instance into XML without annotating Person class?
BTW, here it is the code I use, but it fails because of the missing annotation :
String result;
Person person = personManager.findByPersonId(personId);
StringWriter sw = new StringWriter();
JAXBContext personContext = JAXBContext.newInstance(Person.class);
Marshaller personMarshaller = personContext.createMarshaller();
personMarshaller.marshal(person, sw);
result = sw.toString();
return Response.status(200).entity(result).build();
Thank you a lot.