|
From: Gregor J. <gr...@ja...> - 2013-07-05 14:43:55
|
Hi,
I have made some custom exceptions (including their mappers) for the rest interfaces in order to allow java clients to catch them explicitly and react to it accordingly rather than receiving an 500 for any error.
I am using the client api to call a remote method (which ends up throwing a custom exception) surrounded by a try-catch-block. Unfortunately my custom exception won't be caught, instead I receive the follow exception:
Jul 05, 2013 4:25:16 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Resteasy] in context with path [] threw exception
java.lang.IllegalStateException: Response is closed.
at org.jboss.resteasy.specimpl.BuiltResponse.abortIfClosed(BuiltResponse.java:254)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.getEntity(ClientResponse.java:76)
at org.jboss.resteasy.core.ExceptionHandler.unwrapException(ExceptionHandler.java:125)
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:74)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Here is a code snippet clarifying what I am doing:
RestInterface {
@GET
@Path("/{id}")
public SomeObject getSomeObject(@PathParam("id") String id) throws MyCustomException;
}
RestProxyInterface {
@GET
@Path("/{id}")
public SomeObject getSomeObject(@PathParam("id") String id){
// create client proxy ... --> remoteRestInterface
try {
SomeObject someObject = remoteRestInterface.getSomeObject(id);
}catch (MyCustomException e) {
logger.error(e); // won't get here.. instead throws the above described exception
}
}
}
Is it possible to achieve what I am trying to do? If yes, how?
Thanks.
Gregor
|