ExceptionMapper and internal exceptions

Help
2011-09-28
2013-06-06
  • Colin Rogers

    Colin Rogers - 2011-09-28

    There are two things I'm trying to achieve. I'm using RestEasy from JBoss 6.0.0.Final.

    First is to turn off the logging for NotFoundExceptions thrown in ResteasyHandlerMapping. Despite my log4j.xml reading;

    <logger name="org.jboss.resteasy.springmvc.ResteasyHandlerMapping">
        <level value="off" />
    </logger>
    

    ResteasyHandlerMapping class still reports the error. I've ensured that LOG4J or SLF4J are specified in the "resteasy.logger.type" web.xml context-param, but neither work. The exception is still logged, as below;

    16:01:48,441 WARN  [org.jboss.resteasy.springmvc.ResteasyHandlerMapping] Resource Not Found: Could not find resource for relative : /invalid
    /endpoint of full path: http://aserver/invalid/endpoint: org.jboss.resteasy.spi.NotFoundException: Could not find resource for
    relative : /invalid/endpoint of full path: http://aserver/invalid/endpoint
            at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:360) [:]
            at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374) [:]
            at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367) [:]
    

    Secondly, I'd like to handle the exception and return a more meaning response. I've created and registered an exception mapper as per the example below;

    @Provider public class NotFoundExceptionMapper implements ExceptionMapper<org.jboss.resteasy.spi.NotFoundException>
    

    And it's registered in the class with the web.xml context-param "resteasy.providers", and specified in Spring as a bean.

    Again, the exception mapper is never used to handle the exception and ultimately produces some HTML reporting a 404.

    I've other exception mappers that work fine in capturing different exceptions thrown within an end point - so I'm assuming general exception mappers are fine, but despite the documentation claiming "You may override Resteasy built-in exceptions by writing an ExceptionMapper for the exception." - I can't seem to get exception mappers to handle internal RestEasy exceptions.

    Any help would be gratefully appreciated.

     
  • Merrin Kurian

    Merrin Kurian - 2011-11-29

    Have you found a solution yet? I also face the same issue now. We used to have exception mappers that work correctly(to wrap 500 errors in a 200 error) before integrating with Spring. Now, after spring integration, this wrapping of 500 in 200 is not working. The closest I have come to is this post: http://stackoverflow.com/questions/5036166/springmvc-resteasy-and-exception-mapping
    I haven't been able to take a stab at it again.

    f you have any useful update, please let me know.
    Thanks
    Merrin

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks