I just wrote up this bug: https://jira.springsource.org/browse/SPR-10090
But I wanted to check here and make sure I'm not doing anything wrong. I have an @Controller class that defines an @ExceptionHandler that returns a ResponseEntity:
Pretty straightforward. But it throws an exception:Code:@ExceptionHandler(java.lang.Exception.class) public ResponseEntity<String> handleException(java.lang.Exception inEx) { ... }
and the source code doesn't seem to be able to handle anything that doesn't turn into a ModelAndView. However, the docs are pretty clear that the RequestEntity return type is supported, and there are even other classes provided by Spring that do that.Code:00:50:42.949 ERROR annotation.AnnotationMethodHandlerExceptionResolver (AnnotationMethodHandlerExceptionResolver.java:147) Invoking request method resulted in exception : public org.springframework.http.ResponseEntity com.latencyzero.gamecenter.web.ServiceController.handleException(java.lang.Exception) java.lang.IllegalArgumentException: Invalid handler method return value: <500 Internal Server Error,{"resultMsg":"Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open connection","result":1},{Content-Type=[application/json;charset=UTF-8]}> at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver.getModelAndView(AnnotationMethodHandlerExceptionResolver.java:414) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver.doResolveException(AnnotationMethodHandlerExceptionResolver.java:144) at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136) at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1148) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:985) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:917) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:813) at javax.servlet.http.HttpServlet.service(HttpServlet.java:120) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:798) at javax.servlet.http.HttpServlet.service(HttpServlet.java:97)
So, am I missing something? Thanks!


Reply With Quote
