JAXB (JSR-222) implementations do not require any annotations be added to your domain model. In the absence of an @XmlRootElement
(or @XmlElementDecl
) you simply need to wrap your root object in an instance of JAXBElement.
JAXBElement<Person> jaxbElement = new JAXBElement<Person>(new QName("person"), Person.class, person);
personMarshaller.marshal(jaxbElement, sw);
For More Information
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
If you need to provide metadata for your model, but don't have access to the source then MOXy offers an external metadata document extension you can use for this purpose.
Thank you, the link you gave me is useful, but I wonder if this EclipseLink library is safe to integrate in a commercial product (license)...
MOXy has been the default JAXB implementation in WebLogic since version 12.1.1, so it's definitely enterprise ready.
EclipseLink (and MOXy) is dual licensed under the Eclipse Public License and Eclipse Distribution License (BSD):