You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kiril Gavrailov <kg...@gmail.com> on 2013/07/06 11:56:16 UTC
Registering custom json provider for user model resources
Hi,
I have the following case:
I have an annotated resource which is registered as resource into the
singletons of my Application on a specific alias. I wanted to expose only
parts of this resource to a different alias, so what I did is that I
exposed the methods of the resource I wanted as an user model (as descibed
here:
http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations)
. Which worked just fine, I mean the resource gets registered, invoked
successfully and so on, however when returning response I got http response
500.
The only clue I saw in the logs was:
2013 07 06
12:36:35#+0300#WARN#org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor##anonymous#http-bio-8443-exec-28###No
message body writer has been found for response class Vector.
So after a bit more debugging I noticed that my messageWriters are empty,
i.e. my custom Gson json provider is not taken into consideration and
therefor it cannot serialize the response to json. My custom json provider
is injected with @Provider annotation(I'm not using spring) and works
perfectly fine when I invoke the very same method but through my other
alias.
So, is there a way to point the json provider for resource registered as
resources without annotations?
Big Thanks in advance.
Regards,
Kiril
Re: Registering custom json provider for user model resources
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
Yes, that can be added in web.xml.
thanks, Sergey
On 07/07/13 08:46, Kiril Gavrailov wrote:
> Okay, just realized how dumb question was that :) I just described my
> custom json provider into my web.xml jaxrs.providers for my second
> servlet, which takes care of the user model resources and everything just
> worked fine.
>
> Regards,
> Kiril
>
>
> On Sat, Jul 6, 2013 at 12:56 PM, Kiril Gavrailov <kg...@gmail.com>wrote:
>
>> Hi,
>> I have the following case:
>> I have an annotated resource which is registered as resource into the
>> singletons of my Application on a specific alias. I wanted to expose only
>> parts of this resource to a different alias, so what I did is that I
>> exposed the methods of the resource I wanted as an user model (as descibed
>> here:
>> http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations)
>> . Which worked just fine, I mean the resource gets registered, invoked
>> successfully and so on, however when returning response I got http response
>> 500.
>>
>> The only clue I saw in the logs was:
>> 2013 07 06 12:36:35#+0300#WARN#org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor##anonymous#http-bio-8443-exec-28###No
>> message body writer has been found for response class Vector.
>>
>> So after a bit more debugging I noticed that my messageWriters are empty,
>> i.e. my custom Gson json provider is not taken into consideration and
>> therefor it cannot serialize the response to json. My custom json provider
>> is injected with @Provider annotation(I'm not using spring) and works
>> perfectly fine when I invoke the very same method but through my other
>> alias.
>>
>> So, is there a way to point the json provider for resource registered as
>> resources without annotations?
>>
>> Big Thanks in advance.
>>
>> Regards,
>> Kiril
>>
>
Re: Registering custom json provider for user model resources
Posted by Kiril Gavrailov <kg...@gmail.com>.
Okay, just realized how dumb question was that :) I just described my
custom json provider into my web.xml jaxrs.providers for my second
servlet, which takes care of the user model resources and everything just
worked fine.
Regards,
Kiril
On Sat, Jul 6, 2013 at 12:56 PM, Kiril Gavrailov <kg...@gmail.com>wrote:
> Hi,
> I have the following case:
> I have an annotated resource which is registered as resource into the
> singletons of my Application on a specific alias. I wanted to expose only
> parts of this resource to a different alias, so what I did is that I
> exposed the methods of the resource I wanted as an user model (as descibed
> here:
> http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations)
> . Which worked just fine, I mean the resource gets registered, invoked
> successfully and so on, however when returning response I got http response
> 500.
>
> The only clue I saw in the logs was:
> 2013 07 06 12:36:35#+0300#WARN#org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor##anonymous#http-bio-8443-exec-28###No
> message body writer has been found for response class Vector.
>
> So after a bit more debugging I noticed that my messageWriters are empty,
> i.e. my custom Gson json provider is not taken into consideration and
> therefor it cannot serialize the response to json. My custom json provider
> is injected with @Provider annotation(I'm not using spring) and works
> perfectly fine when I invoke the very same method but through my other
> alias.
>
> So, is there a way to point the json provider for resource registered as
> resources without annotations?
>
> Big Thanks in advance.
>
> Regards,
> Kiril
>