java - ExceptionMapper in Jersey throws mapMappableContainerException -
i have created 1 rest services , wanted implement exception handling throws mapmappablecontainerexception while try run services. can find code here.
myservice :
@get @produces({mediatype.application_json}) @path("add") public response addjobseeker() throws mycustomexception{ throw new mycustomexception("my exception"); }
my exception class.
@provider public class myexceptionmapper extends exception implements exceptionmapper<mycustomexception>{ /** * */ private static final long serialversionuid = 1l; public myexceptionmapper(string str){ super(str); } @override public response toresponse(mycustomexception exception) { system.out.println("in exception mapper -- "+exception.getmessage()); success sc = new success(404, "hello", "i mukesh"); return response.status(404).entity(sc).type(mediatype.application_json).build(); } }
mycustomclass
public class mycustomexception extends exception { /** * */ private static final long serialversionuid = 1l; public mycustomexception(string str){ super(str); }
Comments
Post a Comment