Hi all, here's the problem:
@XmlRootElement
@XmlSeeAlso({
Client.class,
Invoice.class
})
public class HTTPResponse {
private int code;
private Object data;
... getters and setters ..
}
@Path("invoice")
public class InvoiceService {
... others methods ...
/**
* Return a list of invoices created for the client.
*
* @param email, client's email
* @return
*/
@GET
@Path("{email:[^@]+@[^\\.]+(\\.[^\\.]+)+}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public HTTPResponse list(@PathParam("email") String email){
HTTPResponse response = new HTTPResponse();
try{
Invoice[] list = InvoiceDAO.list(email);
response.setCode(ServiceStatus.SUCCESS);
response.setData(list);
} catch (NoResultException e) {
response.setCode(ServiceStatus.NOT_FOUND);
response.setData("No invoices found for client with email: " + email);
}
return response;
}
... more code ...
}
So, in other methods that a simple Invoice object was set with
HTTPResponse.setData all works, but in method List, when I need to return a
list of invoices, the JAXB marshalling return an error that I couldn't fix:
[javax.xml.bind.JAXBException: class [Lcom.mystore.payment.entity.Invoice;
nor any of its super class is known to this context.]
--
Rafael Nunes Verger -- Software Developer