CXF default exception mapper config

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CXF default exception mapper config

Felipe Jaekel
Hi,

I'm working in a REST service that throws WebApplicationExcepion with
custom messages. I need pass the custom exception message to the client,
but it is ignored. After some search, I found that
the WebApplicationExceptionMapper was the responsible for ignoring the
exception message, but it has a parameter addMessageToResponse. Setting it
to true while debugging on Eclipse works as expected. So my question is how
do I set this parameter on TomEE config? The CXF documentation shows how to
do it using Spring, but I'm using pure Java EE.

https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-CustomizingdefaultWebApplicationExceptionmapper

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: CXF default exception mapper config

Cesar Hernandez
I haven't implemented your scenario yet but it seems it's related with the
configuration on the openejb-jar.xml file [1]:


In the openejb-jar.xml put

> <openejb-jar xmlns="openejb.org/openejb-jar/1.1">
>  <pojo-deployment class-name="jaxrs-application">
>    <properties>
>           cxf.jaxrs.providers = namespace.YourCustomExceptionMapper
>    </properties>
>  </pojo-deployment>
> </openejb-jar>



[1]
https://stackoverflow.com/questions/34234609/how-can-i-enable-my-custom-exceptionmapper-in-tomee





El mié., 19 jun. 2019 a las 7:29, Felipe Jaekel (<[hidden email]>)
escribió:

> Hi,
>
> I'm working in a REST service that throws WebApplicationExcepion with
> custom messages. I need pass the custom exception message to the client,
> but it is ignored. After some search, I found that
> the WebApplicationExceptionMapper was the responsible for ignoring the
> exception message, but it has a parameter addMessageToResponse. Setting it
> to true while debugging on Eclipse works as expected. So my question is how
> do I set this parameter on TomEE config? The CXF documentation shows how to
> do it using Spring, but I'm using pure Java EE.
>
>
> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-CustomizingdefaultWebApplicationExceptionmapper
>
> Thanks
>


--
Atentamente:
César Hernández.
Reply | Threaded
Open this post in threaded view
|

Re: CXF default exception mapper config

Felipe Jaekel
Thanks for the feedback.

I was able to send the exception message to the client with this tutorial:
http://blog.ignacio.org.mx/posts/jax-rs-exception-handling/

It works even better than the default WebApplicationExceptionMapper as I
don't require additional parsing to get the exception message, but I'm
still curious on how to set the addMessageToResponse property of the
default WebApplicationExceptionMapper without using Spring.

Em seg, 24 de jun de 2019 às 19:08, César Hernández Mendoza <
[hidden email]> escreveu:

> I haven't implemented your scenario yet but it seems it's related with the
> configuration on the openejb-jar.xml file [1]:
>
>
> In the openejb-jar.xml put
>
> > <openejb-jar xmlns="openejb.org/openejb-jar/1.1">
> >  <pojo-deployment class-name="jaxrs-application">
> >    <properties>
> >           cxf.jaxrs.providers = namespace.YourCustomExceptionMapper
> >    </properties>
> >  </pojo-deployment>
> > </openejb-jar>
>
>
>
> [1]
>
> https://stackoverflow.com/questions/34234609/how-can-i-enable-my-custom-exceptionmapper-in-tomee
>
>
>
>
>
> El mié., 19 jun. 2019 a las 7:29, Felipe Jaekel (<[hidden email]>)
> escribió:
>
> > Hi,
> >
> > I'm working in a REST service that throws WebApplicationExcepion with
> > custom messages. I need pass the custom exception message to the client,
> > but it is ignored. After some search, I found that
> > the WebApplicationExceptionMapper was the responsible for ignoring the
> > exception message, but it has a parameter addMessageToResponse. Setting
> it
> > to true while debugging on Eclipse works as expected. So my question is
> how
> > do I set this parameter on TomEE config? The CXF documentation shows how
> to
> > do it using Spring, but I'm using pure Java EE.
> >
> >
> >
> https://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-CustomizingdefaultWebApplicationExceptionmapper
> >
> > Thanks
> >
>
>
> --
> Atentamente:
> César Hernández.
>