users@jersey.java.net

ExceptionMapper and Viewable

From: Jordi Domingo <noseya_at_hotmail.com>
Date: Wed, 30 Sep 2009 13:44:34 +0200

Hi :)



I'm trying to make an ExceptionMapper that returns the response
expected by the client. I dont know how i can return a Viewable or a
JSON response because i dont have access to any object with that
information



 public Response toResponse(EJBException exception) {}



On another side, when Jersey finds an Exception (not Runtime) that is
not mapped, forwards it to the ServletContainer, thats fine. When i do
the same with an EJBException (SystemException) I dont know how to
achieve the same behavior. This is my code for testing:



public Response toResponse(EJBException exception) {

         final Exception cause = exception.getCausedByException();

         

         return new WebApplicationException(cause).getResponse();

     }



Thanks for your help,



Jordi _________________________________________________________________ Nuevo Windows Live, un mundo lleno de posibilidades. Descúbrelo. http://www.microsoft.com/windows/windowslive/default.aspx
--_20f2a5dc-5d7f-4562-8aab-5000a7c21e46_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<br>Hi :)<br>
<br>
I'm trying to make an ExceptionMapper that returns the response
expected by the client. I dont know how i can return a Viewable or a
JSON response because i dont have access to any object with that
information<br>
<br>
&nbsp;public Response toResponse(EJBException exception) {}<br>
<br>
On another side, when Jersey finds an Exception (not Runtime) that is
not mapped, forwards it to the ServletContainer, thats fine. When i do
the same with an EJBException (SystemException) I dont know how to
achieve the same behavior. This is my code for testing:<br>
<br>
public Response toResponse(EJBException exception) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final Exception cause = exception.getCausedByException();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new WebApplicationException(cause).getResponse();<br>
&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
Thanks for your help,<br>
<br>
Jordi <br /><hr />Nuevo Windows Live, un mundo lleno de posibilidades <a href='http://www.microsoft.com/windows/windowslive/default.aspx' target='_new'>Descúbrelo.</a></body>
</html>
--_20f2a5dc-5d7f-4562-8aab-5000a7c21e46_--