You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jason Wang <ja...@gmail.com> on 2014/01/08 03:24:38 UTC

How to turn off stack trace for WebApplicationExceptionMapper in CXF RS 2.7.8?

Hi all,

I noticed that for exceptions such as BadRequestException, the
WebApplicationExceptionMapper nicely translate it into reponse but also
logs the entire track with warn level.

I think that Mapper is automatically added as a provider (I am using jaxrs
2.7.8 and  Oauth 2 module).

I can see that the exception mapper actually has a flag
called printStackTrace.

But it seems the mapper got added by the ProviderFactory as the default.

So my question is, how do I get a reference to that mapper and call the
setter to mute the stack trace?

Cheers,
Jason

Re: How to turn off stack trace for WebApplicationExceptionMapper in CXF RS 2.7.8?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi All,
The JAX-RS way is to register a custom provider, so in this case either 
custom WebApplicationMapper or CXF one with a property set can be listed 
in jaxrs:providers

Cheers, Sergey


On 10/01/14 10:43, Andrei Shakirin wrote:
> Hi Jason,
>
> Yes, please.
> Patch is also always welcome :)
>
> Regards,
> Andrei.
>
>> -----Original Message-----
>> From: Jason Wang [mailto:jason.lei.wang@gmail.com]
>> Sent: Freitag, 10. Januar 2014 00:49
>> To: users@cxf.apache.org
>> Subject: RE: How to turn off stack trace for WebApplicationExceptionMapper
>> in CXF RS 2.7.8?
>>
>> Thanks Andrei. Do you want me to log a feature request in Jira? Reflection is
>> definitely not ideal.



RE: How to turn off stack trace for WebApplicationExceptionMapper in CXF RS 2.7.8?

Posted by Andrei Shakirin <as...@talend.com>.
Hi Jason,

Yes, please.
Patch is also always welcome :)

Regards,
Andrei.

> -----Original Message-----
> From: Jason Wang [mailto:jason.lei.wang@gmail.com]
> Sent: Freitag, 10. Januar 2014 00:49
> To: users@cxf.apache.org
> Subject: RE: How to turn off stack trace for WebApplicationExceptionMapper
> in CXF RS 2.7.8?
> 
> Thanks Andrei. Do you want me to log a feature request in Jira? Reflection is
> definitely not ideal.

RE: How to turn off stack trace for WebApplicationExceptionMapper in CXF RS 2.7.8?

Posted by Jason Wang <ja...@gmail.com>.
Thanks Andrei. Do you want me to log a feature request in Jira? Reflection
is definitely not ideal.

RE: How to turn off stack trace for WebApplicationExceptionMapper in CXF RS 2.7.8?

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

You can get the Factory using this code:

Endpoint e = server.getEndpoint();
ProviderFactory factory = (ProviderFactory)e.get(ProviderFactory.class.getName());

Unfortunately factory hasn't getter for the exceptionMappers, as workaround you can access the property using reflection API.
I would consider to add public getter for the providers into ProviderFactory/ServiceProviderFactory.

Regards,
Andrei.

> -----Original Message-----
> From: Jason Wang [mailto:jason.lei.wang@gmail.com]
> Sent: Mittwoch, 8. Januar 2014 03:25
> To: users@cxf.apache.org
> Subject: How to turn off stack trace for WebApplicationExceptionMapper in
> CXF RS 2.7.8?
> 
> Hi all,
> 
> I noticed that for exceptions such as BadRequestException, the
> WebApplicationExceptionMapper nicely translate it into reponse but also
> logs the entire track with warn level.
> 
> I think that Mapper is automatically added as a provider (I am using jaxrs
> 2.7.8 and  Oauth 2 module).
> 
> I can see that the exception mapper actually has a flag called printStackTrace.
> 
> But it seems the mapper got added by the ProviderFactory as the default.
> 
> So my question is, how do I get a reference to that mapper and call the setter
> to mute the stack trace?
> 
> Cheers,
> Jason