【发布时间】:2015-02-01 23:04:58
【问题描述】:
我的异常映射器如下所示
@Provider
public class DAExceptionMapper implements ExceptionMapper<DAException> {
@Override
public @ResponseBody Response toResponse(DAException exception) {
}
}
public class DAException extends Exception {
}
我在 Jetty 8.1.14 上使用 Spring 3.2.5 和 Jersey 2.15。
我找不到为什么我的异常映射器没有在 Spring 中注册。当我在我的应用程序中抛出一个自定义 DAException 时,我得到 500。我尝试了https://java.net/jira/browse/JERSEY-2063 中的所有解决方案。他们都没有工作。
我目前没有在 spring 上下文 xml 中注册的任何异常 bean。我的应用程序没有通过程序设置资源。
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is DAException [responseStatus=Unauthorized, errorMessage=ErrorMessage [errorMessage=User is not allowed to access this resource.], errorDescription=User is not allowed to access this resource.]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
【问题讨论】:
-
尝试使
DAException扩展WebApplicationException -
@peeskillet,可以工作,但我真的想使用界面选项而不是扩展。
标签: java spring rest spring-mvc jersey