You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Aaron Titus <at...@fwdco.com> on 2013/09/26 20:01:00 UTC

configure date format with Jackson 1.9

Hello All,

I have a question that I have been unable to answer looking through google
and stackoverflow.  I am using Apache CXF 2.7.6,  and also Jackson 1.9
configured as the provideer for Jaxb to JSON mapping.  It works except
dates are serialized as long numbers.

I found instructions online on how to configure this in the cxf-servlet.xml
file, by setting the serializationConfig.dateFormat property.  However this
apparently only applies to older Jackson versions, as it does not work with
1.9.

There are plenty of examples of how to do this in plain code, however I
need to know how to do it in the configuration file so that CXF will create
the provider instance with the correct configuration.  Can anyone point me
in the right direction?   Thanks in advance!

Aaron

Re: configure date format with Jackson 1.9

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 09/10/13 15:07, Aaron Titus wrote:
> Hi Everyone,
>
> I tried to do what Sergey suggested, but with some undesirable results.
>   The classes have jax-ws annotations as well as jax-rs, because the same
> functionality needs to be available for both REST and SOAP interfaces. CXF
> ends up creating SOAP endpoints at the URL which I have designated for the
> non-spring REST servlet.   I  **REALLY** don't want to have to maintain two
> sets of classes here, which implement the exact same thing, just to be able
> to configure REST. Is there any possible way I can configure jackson
> through spring to be able to control the date function???
>
I'm not sure why using JAX-RS Application instance can have the effect 
on selecting JAX-WS & JAX-RS endpoints ?

> I originally started out using jettison and this all worked beautifully
> with the spring configuration.  But I was forced to replace jettison with
> JAX-RS due to a pretty substantial limitation in Jettison with array
> serialization that doesn't look like its going to be addressed any time
> soon.
Yes, at the moment this issue can only be sorted out with the manula 
configuration; there was some internal discussion about doing a more 
advanced solution in Jettison, but I'm not sure at the moment what will 
come out of it

Sergey
>
> Thanks in advance,
> Aaron
>
>
>
>
> On Thu, Sep 26, 2013 at 4:40 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi
>>
>>
>>
>> On 26/09/13 19:01, Aaron Titus wrote:
>>
>>> Hello All,
>>>
>>> I have a question that I have been unable to answer looking through google
>>> and stackoverflow.  I am using Apache CXF 2.7.6,  and also Jackson 1.9
>>> configured as the provideer for Jaxb to JSON mapping.  It works except
>>> dates are serialized as long numbers.
>>>
>>> I found instructions online on how to configure this in the
>>> cxf-servlet.xml
>>> file, by setting the serializationConfig.dateFormat property.  However
>>> this
>>> apparently only applies to older Jackson versions, as it does not work
>>> with
>>> 1.9.
>>>
>>> There are plenty of examples of how to do this in plain code, however I
>>> need to know how to do it in the configuration file so that CXF will
>>> create
>>> the provider instance with the correct configuration.  Can anyone point me
>>> in the right direction?   Thanks in advance!
>>>
>>
>> The simplest option to do without Spring is to create a custom JAX-RS
>> Application, initialize your Jackson provider instance as needed and return
>> in Application getSingletons method, then register your Application class,
>> you will find an example of how to register in this section:
>>
>> http://cxf.apache.org/docs/**jaxrs-services-configuration.**html#**
>> JAXRSServicesConfiguration-**ConfiguringJAXRSservicesincont**
>> ainerwithoutSpring<http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAXRSservicesincontainerwithoutSpring>
>>
>> Sergey
>>
>>
>>> Aaron
>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: configure date format with Jackson 1.9

Posted by Aaron Titus <at...@fwdco.com>.
Hi Everyone,

I tried to do what Sergey suggested, but with some undesirable results.
 The classes have jax-ws annotations as well as jax-rs, because the same
functionality needs to be available for both REST and SOAP interfaces. CXF
ends up creating SOAP endpoints at the URL which I have designated for the
non-spring REST servlet.   I  **REALLY** don't want to have to maintain two
sets of classes here, which implement the exact same thing, just to be able
to configure REST. Is there any possible way I can configure jackson
through spring to be able to control the date function???

I originally started out using jettison and this all worked beautifully
with the spring configuration.  But I was forced to replace jettison with
JAX-RS due to a pretty substantial limitation in Jettison with array
serialization that doesn't look like its going to be addressed any time
soon.

Thanks in advance,
Aaron




On Thu, Sep 26, 2013 at 4:40 PM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi
>
>
>
> On 26/09/13 19:01, Aaron Titus wrote:
>
>> Hello All,
>>
>> I have a question that I have been unable to answer looking through google
>> and stackoverflow.  I am using Apache CXF 2.7.6,  and also Jackson 1.9
>> configured as the provideer for Jaxb to JSON mapping.  It works except
>> dates are serialized as long numbers.
>>
>> I found instructions online on how to configure this in the
>> cxf-servlet.xml
>> file, by setting the serializationConfig.dateFormat property.  However
>> this
>> apparently only applies to older Jackson versions, as it does not work
>> with
>> 1.9.
>>
>> There are plenty of examples of how to do this in plain code, however I
>> need to know how to do it in the configuration file so that CXF will
>> create
>> the provider instance with the correct configuration.  Can anyone point me
>> in the right direction?   Thanks in advance!
>>
>
> The simplest option to do without Spring is to create a custom JAX-RS
> Application, initialize your Jackson provider instance as needed and return
> in Application getSingletons method, then register your Application class,
> you will find an example of how to register in this section:
>
> http://cxf.apache.org/docs/**jaxrs-services-configuration.**html#**
> JAXRSServicesConfiguration-**ConfiguringJAXRSservicesincont**
> ainerwithoutSpring<http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAXRSservicesincontainerwithoutSpring>
>
> Sergey
>
>
>> Aaron
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>

Re: configure date format with Jackson 1.9

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi


On 26/09/13 19:01, Aaron Titus wrote:
> Hello All,
>
> I have a question that I have been unable to answer looking through google
> and stackoverflow.  I am using Apache CXF 2.7.6,  and also Jackson 1.9
> configured as the provideer for Jaxb to JSON mapping.  It works except
> dates are serialized as long numbers.
>
> I found instructions online on how to configure this in the cxf-servlet.xml
> file, by setting the serializationConfig.dateFormat property.  However this
> apparently only applies to older Jackson versions, as it does not work with
> 1.9.
>
> There are plenty of examples of how to do this in plain code, however I
> need to know how to do it in the configuration file so that CXF will create
> the provider instance with the correct configuration.  Can anyone point me
> in the right direction?   Thanks in advance!

The simplest option to do without Spring is to create a custom JAX-RS 
Application, initialize your Jackson provider instance as needed and 
return in Application getSingletons method, then register your 
Application class, you will find an example of how to register in this 
section:

http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAXRSservicesincontainerwithoutSpring

Sergey

>
> Aaron
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com