You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ivan Vitoria Sanchez <iv...@grupoica.com> on 2011/04/11 10:25:51 UTC

Using Date instead of XmlGregorianCalendarImpl

Hello,

 

Is there any way to configure (via Spring) the JAXB provider in order to use
"Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
having XmlGregorianCalendarImpl instances when using a class which extend
from a generic type class and specifying Date as the type in my subclass.

 

Many thanks,

 

Ivan

 


RE: Using Date instead of XmlGregorianCalendarImpl

Posted by Ivan Vitoria Sanchez <iv...@grupoica.com>.
Umm.. another library issue getting in my way!

 

Well, I’ve found a bypass annotating both container and contained classes
with two adapters that have the conversion of XMLGregorianCalendarImpl to
Date… I’d prefer a more standardized solution instead… 

 

Thanks,

 

Ivan

 

De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: miércoles, 13 de abril de 2011 10:45
Para: Ivan Vitoria Sanchez
CC: users@cxf.apache.org
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

 

Hi Ivan

It looks like a JAXB issue to me. I don't understand why referencing the
adapter from a package-info.java for serializing the Date leads to that
exception - CXF JAXBElementProvider is not involved at that stage. With
JAX-WS, this customization (at the schema level) actually leads to adapters
being generated and declarations added to the fields...
The fact that the adapter is not activated when DateField is a list member
seems like a bug to me, or may be you need to annotate the List field
itself, not really sure

Cheers, Sergey



On Wed, Apr 13, 2011 at 9:12 AM, Ivan Vitoria Sanchez
<iv...@grupoica.com> wrote:

Hi Sergey,

 

Adding the adapter to the DateField class works if I send this class as a
root of my payload. However, if other class has a DateField within a List
(this is my real scenario) the adapter is not activated. If I add the
adapter either to the package level or the field/property level, a
JAXBException is thrown:

 

Payload: JAXBException occurred : unexpected element (uri:"",
local:"priority"). Expected elements are <{}genericBean>. unexpected element
(uri:"", local:"priority"). Expected elements are <{}genericBean>.

 

This is the payload, which works with XMLGregorioanCalendarImpl if I don’t
annotate any field/property with the adapter:

 

<?xml version="1.0" encoding="utf-8" ?>

<priority xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<fieldList>

<field xsi:type="dateField"> 

   <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>

   <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>

</field>

</fieldList>

</priority>

 

Thanks for your patience… :P

 

Cheers!

 

Ivan

 

¡De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: martes, 12 de abril de 2011 16:27
Para: Ivan Vitoria Sanchez
CC: users@cxf.apache.org


Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

 

Hi Ivan

I think you should then add the adapter to the DateField class itself, to
the maxValue field, or add it to package-info.java, that should fix it

thanks, Sergey

On Tue, Apr 12, 2011 at 3:09 PM, Ivan Vitoria Sanchez
<iv...@grupoica.com> wrote:

Hi Sergey,

 

It’s the same scenario that you have seen before in other JIRAs. At this
time, I’m trying to put/post data. There is no problem if my POJO (annotated
with @XmlRootElement) has Date attributes:

 

<workOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <completionDate>2015-02-27T17:08:46.300+01:00</completionDate>

<!-- other tags omitted -->

</workOrder>

 

The problem comes when I’ve this kind of entity:

 

public abstract class InputField<T> extends GenericBean<InputField<T>>

{

                T value;

                // getter & setter omitted

}

 

public class DateField extends InputField<Date>

{

                private Date maxValue;

                // getter & setter omitted

}

 

And my XML looks like this:

 

<dateField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>

   <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>

</dateField>

 

It seems as if the Java instance becomes
InputField<XMLGregorianCalendarImpl> instead of DateField.

 

Hope this helps!

 

Cheers,

 

Ivan

 

De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: martes, 12 de abril de 2011 15:16


Para: users@cxf.apache.org

CC: Ivan Vitoria Sanchez


Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

 

Hi Ivan

On Mon, Apr 11, 2011 at 3:19 PM, Ivan Vitoria Sanchez
<iv...@grupoica.com> wrote:

Hi Sergey,

The problem is that my method returns T, which is resolved by
XMLGregorianCalendar instead of Date.

Is this method a JAX-RS resource method ? Or is it part of the JAXB bean
class ?
I don't think returning a Date directly from a resource method would work
with JAXBElementProvider 

Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes a
JAXBException (unexpected element).

Can you provide more info please ?

thanks, Sergey
 

Ivan


-----Mensaje original-----
De: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Enviado el: lunes, 11 de abril de 2011 12:45
Para: users@cxf.apache.org
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl


Hi Ivan

You have to add an adapter, please see

http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and

for an example.

JAXBElementProvider won't check package-level adapters, at the moment you'll
probably need to add it to a method returning a Date. I'll see what has be
improved for package-level adapters be checked too

Cheers, Sergey

On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hello,
>
>
>
> Is there any way to configure (via Spring) the JAXB provider in order to
> use
> "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> having XmlGregorianCalendarImpl instances when using a class which extend
> from a generic type class and specifying Date as the type in my subclass.
>
>
>
> Many thanks,
>
>
>
> Ivan
>
>
>
>




-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com> 
http://sberyozkin.blogspot.com

 




-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com> 
http://sberyozkin.blogspot.com


Re: Using Date instead of XmlGregorianCalendarImpl

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

It looks like a JAXB issue to me. I don't understand why referencing the
adapter from a package-info.java for serializing the Date leads to that
exception - CXF JAXBElementProvider is not involved at that stage. With
JAX-WS, this customization (at the schema level) actually leads to adapters
being generated and declarations added to the fields...
The fact that the adapter is not activated when DateField is a list member
seems like a bug to me, or may be you need to annotate the List field
itself, not really sure

Cheers, Sergey


On Wed, Apr 13, 2011 at 9:12 AM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hi Sergey,
>
>
>
> Adding the adapter to the DateField class works if I send this class as a
> root of my payload. However, if other class has a DateField within a List
> (this is my real scenario) the adapter is not activated. If I add the
> adapter either to the package level or the field/property level, a
> JAXBException is thrown:
>
>
>
> Payload: JAXBException occurred : unexpected element (uri:"",
> local:"priority"). Expected elements are <{}genericBean>. unexpected element
> (uri:"", local:"priority"). Expected elements are <{}genericBean>.
>
>
>
> This is the payload, which works with XMLGregorioanCalendarImpl if I don’t
> annotate any field/property with the adapter:
>
>
>
> <?xml version="1.0" encoding="utf-8" ?>
>
> <priority xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="
> http://www.w3.org/2001/XMLSchema">
>
> <fieldList>
>
> <field xsi:type="dateField">
>
>    <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>
>
>    <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>
>
> </field>
>
> </fieldList>
>
> </priority>
>
>
>
> Thanks for your patience… :P
>
>
>
> Cheers!
>
>
>
> Ivan
>
>
>
> *¡**De:* Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> *Enviado el:* martes, 12 de abril de 2011 16:27
> *Para:* Ivan Vitoria Sanchez
> *CC:* users@cxf.apache.org
>
> *Asunto:* Re: Using Date instead of XmlGregorianCalendarImpl
>
>
>
> Hi Ivan
>
> I think you should then add the adapter to the DateField class itself, to
> the maxValue field, or add it to package-info.java, that should fix it
>
> thanks, Sergey
>
> On Tue, Apr 12, 2011 at 3:09 PM, Ivan Vitoria Sanchez <
> ivitoria@grupoica.com> wrote:
>
> Hi Sergey,
>
>
>
> It’s the same scenario that you have seen before in other JIRAs. At this
> time, I’m trying to put/post data. There is no problem if my POJO (annotated
> with @XmlRootElement) has Date attributes:
>
>
>
> <workOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>       <completionDate>2015-02-27T17:08:46.300+01:00</completionDate>
>
> <!-- other tags omitted -->
>
> </workOrder>
>
>
>
> The problem comes when I’ve this kind of entity:
>
>
>
> public abstract class InputField<T> extends GenericBean<InputField<T>>
>
> {
>
>                 T value;
>
>                 // getter & setter omitted
>
> }
>
>
>
> public class DateField extends InputField<Date>
>
> {
>
>                 private Date maxValue;
>
>                 // getter & setter omitted
>
> }
>
>
>
> And my XML looks like this:
>
>
>
> <dateField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>    <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>
>
>    <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>
>
> </dateField>
>
>
>
> It seems as if the Java instance becomes
> InputField<XMLGregorianCalendarImpl> instead of DateField.
>
>
>
> Hope this helps!
>
>
>
> Cheers,
>
>
>
> Ivan
>
>
>
> *De:* Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> *Enviado el:* martes, 12 de abril de 2011 15:16
>
>
> *Para:* users@cxf.apache.org
>
> *CC:* Ivan Vitoria Sanchez
>
>
> *Asunto:* Re: Using Date instead of XmlGregorianCalendarImpl
>
>
>
> Hi Ivan
>
> On Mon, Apr 11, 2011 at 3:19 PM, Ivan Vitoria Sanchez <
> ivitoria@grupoica.com> wrote:
>
> Hi Sergey,
>
> The problem is that my method returns T, which is resolved by
> XMLGregorianCalendar instead of Date.
>
> Is this method a JAX-RS resource method ? Or is it part of the JAXB bean
> class ?
> I don't think returning a Date directly from a resource method would work
> with JAXBElementProvider
>
> Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes
> a
> JAXBException (unexpected element).
>
> Can you provide more info please ?
>
> thanks, Sergey
>
>
> Ivan
>
>
> -----Mensaje original-----
> De: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Enviado el: lunes, 11 de abril de 2011 12:45
> Para: users@cxf.apache.org
> Asunto: Re: Using Date instead of XmlGregorianCalendarImpl
>
>
> Hi Ivan
>
> You have to add an adapter, please see
>
> http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and
>
> for an example.
>
> JAXBElementProvider won't check package-level adapters, at the moment
> you'll
> probably need to add it to a method returning a Date. I'll see what has be
> improved for package-level adapters be checked too
>
> Cheers, Sergey
>
> On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <
> ivitoria@grupoica.com
> > wrote:
>
> > Hello,
> >
> >
> >
> > Is there any way to configure (via Spring) the JAXB provider in order to
> > use
> > "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> > having XmlGregorianCalendarImpl instances when using a class which extend
> > from a generic type class and specifying Date as the type in my subclass.
> >
> >
> >
> > Many thanks,
> >
> >
> >
> > Ivan
> >
> >
> >
> >
>
>
>
>
> --
> Sergey Beryozkin
>
> Application Integration Division of Talend <http://www.talend.com>
> http://sberyozkin.blogspot.com
>
>
>



-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com>
http://sberyozkin.blogspot.com

RE: Using Date instead of XmlGregorianCalendarImpl

Posted by Ivan Vitoria Sanchez <iv...@grupoica.com>.
Hi Sergey,

 

Adding the adapter to the DateField class works if I send this class as a
root of my payload. However, if other class has a DateField within a List
(this is my real scenario) the adapter is not activated. If I add the
adapter either to the package level or the field/property level, a
JAXBException is thrown:

 

Payload: JAXBException occurred : unexpected element (uri:"",
local:"priority"). Expected elements are <{}genericBean>. unexpected element
(uri:"", local:"priority"). Expected elements are <{}genericBean>.

 

This is the payload, which works with XMLGregorioanCalendarImpl if I don’t
annotate any field/property with the adapter:

 

<?xml version="1.0" encoding="utf-8" ?>

<priority xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<fieldList>

<field xsi:type="dateField"> 

   <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>

   <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>

</field>

</fieldList>

</priority>

 

Thanks for your patience… :P

 

Cheers!

 

Ivan

 

¡De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: martes, 12 de abril de 2011 16:27
Para: Ivan Vitoria Sanchez
CC: users@cxf.apache.org
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

 

Hi Ivan

I think you should then add the adapter to the DateField class itself, to
the maxValue field, or add it to package-info.java, that should fix it

thanks, Sergey

On Tue, Apr 12, 2011 at 3:09 PM, Ivan Vitoria Sanchez
<iv...@grupoica.com> wrote:

Hi Sergey,

 

It’s the same scenario that you have seen before in other JIRAs. At this
time, I’m trying to put/post data. There is no problem if my POJO (annotated
with @XmlRootElement) has Date attributes:

 

<workOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <completionDate>2015-02-27T17:08:46.300+01:00</completionDate>

<!-- other tags omitted -->

</workOrder>

 

The problem comes when I’ve this kind of entity:

 

public abstract class InputField<T> extends GenericBean<InputField<T>>

{

                T value;

                // getter & setter omitted

}

 

public class DateField extends InputField<Date>

{

                private Date maxValue;

                // getter & setter omitted

}

 

And my XML looks like this:

 

<dateField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>

   <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>

</dateField>

 

It seems as if the Java instance becomes
InputField<XMLGregorianCalendarImpl> instead of DateField.

 

Hope this helps!

 

Cheers,

 

Ivan

 

De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: martes, 12 de abril de 2011 15:16


Para: users@cxf.apache.org

CC: Ivan Vitoria Sanchez


Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

 

Hi Ivan

On Mon, Apr 11, 2011 at 3:19 PM, Ivan Vitoria Sanchez
<iv...@grupoica.com> wrote:

Hi Sergey,

The problem is that my method returns T, which is resolved by
XMLGregorianCalendar instead of Date.

Is this method a JAX-RS resource method ? Or is it part of the JAXB bean
class ?
I don't think returning a Date directly from a resource method would work
with JAXBElementProvider 

Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes a
JAXBException (unexpected element).

Can you provide more info please ?

thanks, Sergey
 

Ivan


-----Mensaje original-----
De: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Enviado el: lunes, 11 de abril de 2011 12:45
Para: users@cxf.apache.org
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl


Hi Ivan

You have to add an adapter, please see

http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and

for an example.

JAXBElementProvider won't check package-level adapters, at the moment you'll
probably need to add it to a method returning a Date. I'll see what has be
improved for package-level adapters be checked too

Cheers, Sergey

On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hello,
>
>
>
> Is there any way to configure (via Spring) the JAXB provider in order to
> use
> "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> having XmlGregorianCalendarImpl instances when using a class which extend
> from a generic type class and specifying Date as the type in my subclass.
>
>
>
> Many thanks,
>
>
>
> Ivan
>
>
>
>




-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com> 
http://sberyozkin.blogspot.com

 


Re: Using Date instead of XmlGregorianCalendarImpl

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

I think you should then add the adapter to the DateField class itself, to
the maxValue field, or add it to package-info.java, that should fix it

thanks, Sergey

On Tue, Apr 12, 2011 at 3:09 PM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hi Sergey,
>
>
>
> It’s the same scenario that you have seen before in other JIRAs. At this
> time, I’m trying to put/post data. There is no problem if my POJO (annotated
> with @XmlRootElement) has Date attributes:
>
>
>
> <workOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>       <completionDate>2015-02-27T17:08:46.300+01:00</completionDate>
>
> <!-- other tags omitted -->
>
> </workOrder>
>
>
>
> The problem comes when I’ve this kind of entity:
>
>
>
> public abstract class InputField<T> extends GenericBean<InputField<T>>
>
> {
>
>                 T value;
>
>                 // getter & setter omitted
>
> }
>
>
>
> public class DateField extends InputField<Date>
>
> {
>
>                 private Date maxValue;
>
>                 // getter & setter omitted
>
> }
>
>
>
> And my XML looks like this:
>
>
>
> <dateField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>    <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>
>
>    <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>
>
> </dateField>
>
>
>
> It seems as if the Java instance becomes
> InputField<XMLGregorianCalendarImpl> instead of DateField.
>
>
>
> Hope this helps!
>
>
>
> Cheers,
>
>
>
> Ivan
>
>
>
> *De:* Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> *Enviado el:* martes, 12 de abril de 2011 15:16
>
> *Para:* users@cxf.apache.org
> *CC:* Ivan Vitoria Sanchez
>
> *Asunto:* Re: Using Date instead of XmlGregorianCalendarImpl
>
>
>
> Hi Ivan
>
> On Mon, Apr 11, 2011 at 3:19 PM, Ivan Vitoria Sanchez <
> ivitoria@grupoica.com> wrote:
>
> Hi Sergey,
>
> The problem is that my method returns T, which is resolved by
> XMLGregorianCalendar instead of Date.
>
> Is this method a JAX-RS resource method ? Or is it part of the JAXB bean
> class ?
> I don't think returning a Date directly from a resource method would work
> with JAXBElementProvider
>
> Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes
> a
> JAXBException (unexpected element).
>
> Can you provide more info please ?
>
> thanks, Sergey
>
>
> Ivan
>
>
> -----Mensaje original-----
> De: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Enviado el: lunes, 11 de abril de 2011 12:45
> Para: users@cxf.apache.org
> Asunto: Re: Using Date instead of XmlGregorianCalendarImpl
>
>
> Hi Ivan
>
> You have to add an adapter, please see
>
> http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and
>
> for an example.
>
> JAXBElementProvider won't check package-level adapters, at the moment
> you'll
> probably need to add it to a method returning a Date. I'll see what has be
> improved for package-level adapters be checked too
>
> Cheers, Sergey
>
> On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <
> ivitoria@grupoica.com
> > wrote:
>
> > Hello,
> >
> >
> >
> > Is there any way to configure (via Spring) the JAXB provider in order to
> > use
> > "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> > having XmlGregorianCalendarImpl instances when using a class which extend
> > from a generic type class and specifying Date as the type in my subclass.
> >
> >
> >
> > Many thanks,
> >
> >
> >
> > Ivan
> >
> >
> >
> >
>
>
>
>
> --
> Sergey Beryozkin
>
> Application Integration Division of Talend <http://www.talend.com>
> http://sberyozkin.blogspot.com
>

RE: Using Date instead of XmlGregorianCalendarImpl

Posted by Ivan Vitoria Sanchez <iv...@grupoica.com>.
Hi Sergey,

 

It's the same scenario that you have seen before in other JIRAs. At this
time, I'm trying to put/post data. There is no problem if my POJO (annotated
with @XmlRootElement) has Date attributes:

 

<workOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <completionDate>2015-02-27T17:08:46.300+01:00</completionDate>

<!-- other tags omitted -->

</workOrder>

 

The problem comes when I've this kind of entity:

 

public abstract class InputField<T> extends GenericBean<InputField<T>>

{

                T value;

                // getter & setter omitted

}

 

public class DateField extends InputField<Date>

{

                private Date maxValue;

                // getter & setter omitted

}

 

And my XML looks like this:

 

<dateField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <maxValue>2011-04-12T15:51:37.489+02:00</maxValue>

   <value xsi:type="xs:dateTime">2011-04-12T15:51:37.977+02:00</value>

</dateField>

 

It seems as if the Java instance becomes
InputField<XMLGregorianCalendarImpl> instead of DateField.

 

Hope this helps!

 

Cheers,

 

Ivan

 

De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: martes, 12 de abril de 2011 15:16
Para: users@cxf.apache.org
CC: Ivan Vitoria Sanchez
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

 

Hi Ivan

On Mon, Apr 11, 2011 at 3:19 PM, Ivan Vitoria Sanchez
<iv...@grupoica.com> wrote:

Hi Sergey,

The problem is that my method returns T, which is resolved by
XMLGregorianCalendar instead of Date.

Is this method a JAX-RS resource method ? Or is it part of the JAXB bean
class ?
I don't think returning a Date directly from a resource method would work
with JAXBElementProvider 



Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes a
JAXBException (unexpected element).

Can you provide more info please ?

thanks, Sergey
 

Ivan


-----Mensaje original-----
De: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Enviado el: lunes, 11 de abril de 2011 12:45
Para: users@cxf.apache.org
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl


Hi Ivan

You have to add an adapter, please see

http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and

for an example.

JAXBElementProvider won't check package-level adapters, at the moment you'll
probably need to add it to a method returning a Date. I'll see what has be
improved for package-level adapters be checked too

Cheers, Sergey

On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hello,
>
>
>
> Is there any way to configure (via Spring) the JAXB provider in order to
> use
> "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> having XmlGregorianCalendarImpl instances when using a class which extend
> from a generic type class and specifying Date as the type in my subclass.
>
>
>
> Many thanks,
>
>
>
> Ivan
>
>
>
>




-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com> 
http://sberyozkin.blogspot.com


Re: Using Date instead of XmlGregorianCalendarImpl

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

On Mon, Apr 11, 2011 at 3:19 PM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hi Sergey,
>
> The problem is that my method returns T, which is resolved by
> XMLGregorianCalendar instead of Date.
>
> Is this method a JAX-RS resource method ? Or is it part of the JAXB bean
class ?
I don't think returning a Date directly from a resource method would work
with JAXBElementProvider


Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes a
> JAXBException (unexpected element).
>
> Can you provide more info please ?

thanks, Sergey


> Ivan
>
>
> -----Mensaje original-----
> De: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Enviado el: lunes, 11 de abril de 2011 12:45
> Para: users@cxf.apache.org
> Asunto: Re: Using Date instead of XmlGregorianCalendarImpl
>
> Hi Ivan
>
> You have to add an adapter, please see
>
> http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and
>
> for an example.
>
> JAXBElementProvider won't check package-level adapters, at the moment
> you'll
> probably need to add it to a method returning a Date. I'll see what has be
> improved for package-level adapters be checked too
>
> Cheers, Sergey
>
> On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <
> ivitoria@grupoica.com
> > wrote:
>
> > Hello,
> >
> >
> >
> > Is there any way to configure (via Spring) the JAXB provider in order to
> > use
> > "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> > having XmlGregorianCalendarImpl instances when using a class which extend
> > from a generic type class and specifying Date as the type in my subclass.
> >
> >
> >
> > Many thanks,
> >
> >
> >
> > Ivan
> >
> >
> >
> >
>



-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com>
http://sberyozkin.blogspot.com

RE: Using Date instead of XmlGregorianCalendarImpl

Posted by Ivan Vitoria Sanchez <iv...@grupoica.com>.
Hi Sergey,

The problem is that my method returns T, which is resolved by
XMLGregorianCalendar instead of Date.

Adding a @XmlJavaTypeAdapter to the method with a custom XmlAdapter causes a
JAXBException (unexpected element).

Ivan


-----Mensaje original-----
De: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Enviado el: lunes, 11 de abril de 2011 12:45
Para: users@cxf.apache.org
Asunto: Re: Using Date instead of XmlGregorianCalendarImpl

Hi Ivan

You have to add an adapter, please see

http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and

for an example.

JAXBElementProvider won't check package-level adapters, at the moment you'll
probably need to add it to a method returning a Date. I'll see what has be
improved for package-level adapters be checked too

Cheers, Sergey

On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hello,
>
>
>
> Is there any way to configure (via Spring) the JAXB provider in order to
> use
> "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> having XmlGregorianCalendarImpl instances when using a class which extend
> from a generic type class and specifying Date as the type in my subclass.
>
>
>
> Many thanks,
>
>
>
> Ivan
>
>
>
>

Re: Using Date instead of XmlGregorianCalendarImpl

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

You have to add an adapter, please see

http://blogs.sun.com/CoreJavaTechTips/entry/exchanging_data_with_xml_and

for an example.

JAXBElementProvider won't check package-level adapters, at the moment you'll
probably need to add it to a method returning a Date. I'll see what has be
improved for package-level adapters be checked too

Cheers, Sergey

On Mon, Apr 11, 2011 at 9:25 AM, Ivan Vitoria Sanchez <ivitoria@grupoica.com
> wrote:

> Hello,
>
>
>
> Is there any way to configure (via Spring) the JAXB provider in order to
> use
> "Date" instead of "XmlGregorianCalendarImpl" in the JAX-RS server? I'm
> having XmlGregorianCalendarImpl instances when using a class which extend
> from a generic type class and specifying Date as the type in my subclass.
>
>
>
> Many thanks,
>
>
>
> Ivan
>
>
>
>