spring - springmvc-resteasy and exception mapping -


i using resteasy spring mvc integration (springmvc-resteasy using resteasy 2.0, spring 3.0) map application exceptions http responses declaring resteasy exception mapping providers. application not explicitly extend javax.ws.rs.core.application , ideally rely on framework's automatic scanning of exception mapping providers.

here 1 of exception mappers looks like.

@provider public class myappexceptionmapper implements exceptionmapper<myappexception> {     public response toresponse(myappexception exception) {             return response.status(response.status.bad_request).build();     }  } 

and exception class looks this

public class myappexception extends runtimeexception {     public myappexception(string s, throwable t) {      super(s,t);     } } 

when application throws myappexception, not mapped http-400 response (i usual http-500 framework)

is there missing? if problem not "registering" provider framework, how register exception mappers when using springmvc-resteasy?

thanks.

i received answer solomon duskis posting here make sure other folks run issue can solve quickly. suspected, had somehow configure spring configure resteasy scan exception mapping provider. added @component exception mapper , does work mapping myappexception right http response code (in case 400 instead of 500). however, here's caveat: myappexception not serialized resteasy because "java.lang.stacktraceelement not have no-arg default constructor." looking solution secondary issue.

you can either customize component-scan @providers, or add @component exception mapper add context. here's how can scan @providers:

<context:component-scan base-package="bean">     <context:include-filter type="annotation" expression="javax.ws.rs.ext.provider"/> </context:component-scan> 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -