I'm calling this method and getting a 500 back from it.
In the debugger I'm able to step though it all the way to the return statement at the end. No problem, r is populated as expected after Response.build() is called, the status says 200 OK. But that's not what ends up getting produced. I've even told eclipse to break on any Exception.
@GET
@Path("/getAllAppMessagesAsXML")
@Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
public Response getAllAppMessagesXML(@QueryParam("applicationId") String applicationId){
ResponseList list = new ResponseList();
ArrayList<XmlMessageBean> xmlmessages = new ArrayList<>();
try {
List<AppMessage> messages = //Gets from a database
for(AppMessage m : messages){
XmlMessageBean xm = new XmlMessageBean();
xm.setId(m.getId());
xm.setApplicationId(m.getApplicationId());
xm.setMessageBody(m.getMessageBody());
xm.setMessageLevel(m.getMessageLevel());
xm.setMessageTitle(m.getMessageTitle());
xmlmessages.add(xm);
}
} catch (Exception e) {
logger.error("ERROR Failed to save Message AppMessageService.saveAppMessage()", e);
Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
list.setList(xmlmessages);
Response r = null;
try{
r = Response.status(Response.Status.OK).entity(list).build();
}catch(Exception e){
e.printStackTrace();
}
return r;
}
XmlMessageBean.java
@XmlRootElement(name="AppMessage")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlMessageBean {
@XmlElement
private Long id;
@XmlElement
private String applicationId;
@XmlElement
private String messageTitle;
@XmlElement
private String messageBody;
@XmlElement
private String messageLevel;
public XmlMessageBean(){
}
//getters and setters
}
ResponseList.java
@XmlRootElement(name = "ResponseList")
public class ResponseList {
public ResponseList(){
}
@XmlElement(name="list")
private List<XmlMessageBean> list;
public List<XmlMessageBean> getList() {
return list;
}
public void setList(List<XmlMessageBean> list) {
this.list = list;
}
}
I've got this all running in a jersey.servlet.ServletContainer I'm stumped. I can't figure out how to get it to produce any kind of error message other than a generic 500. I've tried setting up an exception mapper as some other posts have mentioned but this also isn't picking anything up.