I have a JAX-RS resource method.
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Some> list() {
final List<Some> list = get();
// list and each elements are ok.
return list;
}
The problem is that application/xml
generates an 500 without any specific server(tomcat) log.
application/json
works fine.
I check JAXB-marshaller for every element in list
.
How can I debug this? How can I test any MessageBodyWriter
for List<Some>
?
UPDATE
The root cause of this problem (500 without a error log) is a wrongly JAXB-annotated class.
I created an ExceptionMapper<Exception>
as @peeskillet suggested.
@Provider
public class MyExceptionMapper implements ExceptionMapper<Exception> {
@Override
public Response toResponse(final Exception exception) {
exception.printStackTrace(System.err);
return Response.serverError().build();
}
}
Then I could see what error JAXB made. I still don't understand why any JAXB-error is not reported.
"How can I debug this?"
Sometimes when errors/exceptions aren't being logged, I'll create an
ExceptionMapper<Throwable or Exception>
and just print the stack trace. If the exception is being thrown in the JAX-RS context, it should go through the mapper.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.