Saturday, 15 June 2013

java - Register an ExceptionMapper in Jersey 2.10.4 -



java - Register an ExceptionMapper in Jersey 2.10.4 -

by default, bailiwick of jersey broken. shows exceptions neither in returned html nor in log file. due deployment constraints cannot utilize xml registration mechanism bailiwick of jersey resources, , doing programatically. next has no effect:

@provider public class exceptiondump implements exceptionmapper<webapplicationexception> { @override public response toresponse(webapplicationexception ex) { string trace = exceptions.getstacktraceasstring(ex); homecoming response.status(500).entity(trace).type("text/plain").build(); } } public class app extends application { @override public set<class<?>> getclasses() { set<class<?>> cls = new hashset<class<?>>(super.getclasses()); cls.add(exceptiondump.class); homecoming cls; } ... }

the grizzly container loads , runs, exception mapper ignored , grizzly still shows "request failed." on errors.

this fixed using (much) higher class webapplicationexception, such throwable. simply, there exceptions thrown not inherit webapplicationexception, it's wrong of examples on web show webapplicationexception without caveat many internal errors go unreported unless more general parent used.

java java-ee java-8 jersey-2.0 grizzly

No comments:

Post a Comment