I've created an XML schema by annotating an existing Java domain model class, now when I try to use JAXB to unmarshall the representation received within my restlet webservice I'm getting a host of errors no matter what I seem to try. I'm new to both restlets and JAXB so pointing me in the direction of a decent example of using both would be helpful only one I've managed to find so far was here: Example
My errors are:
If I try to use the restlet.ext.jaxb JaxbRepresentation:
@Override
public void acceptRepresentation(Representation representation)
throws ResourceException {
JaxbRepresentation<Order> jaxbRep = new JaxbRepresentation<Order>(representation, Order.class);
jaxbRep.setContextPath("com.package.service.domain");
Order order = null;
try {
order = jaxbRep.getObject();
}catch (IOException e) {
...
}
from this I get a
java.io.IOException: Unable to unmarshal the XML representation.Unable to locate unmarshaller.
exception at jaxbRep.getObject()
So I also tried a different approach to see if that made a difference, using the following code instead:
@Override
public void acceptRepresentation(Representation representation)
throws ResourceException {
try{
JAXBContext context = JAXBContext.newInstance(Order.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
Order order = (Order) unmarshaller.unmarshal(representation.getStream());
} catch( UnmarshalException ue ) {
...
} catch( JAXBException je ) {
...
} catch( IOException ioe ) {
...
}
However this also gives me the following exception when call to JAXBContext.newInstance is made.
java.lang.NoClassDefFoundError: javax/xml/bind/annotation/AccessorOrder
Thanks in advance for any advice.