Problem with dateTime, unmarshalling error

Hi,

I have a web service that retuns a DateTime datatype element :

<xsd:element name=“dateEffect” type=“xsd:dateTime”/>

In some cases, this web service can return a “dateEffect” = null.

When I try my web service in SoapUI, this works well without error :


<request>
  <dateEffect/>    --> null value
</request>

Testing within webMethods, it works too.
Testing within a web browser, it works too.

but when I try to call it with a Java-CXF calls, I obtain the error below.

The CXF generator transforms the dateTime element in XMLGregorianCalendar :


    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar dateFinEffet;

org.apache.cxf.interceptor.Fault: Unmarshalling Error:  
	at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:882)
	at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:703)
	at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160)
....

Caused by: java.lang.IllegalArgumentException: 
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseAndSetYear(XMLGregorianCalendarImpl.java:2887)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(XMLGregorianCalendarImpl.java:2773)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:435)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:536)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:586)
	... 35 more

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error:  
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:159)
	at com.sun.proxy.$Proxy34.getContratsRentes(Unknown Source)
	at com.mif.simuws.tests.contratsrentes.WsContratsRentesPortType_MifMetierSynchroneWsProviderWsContratsRentesPort_Client.main(WsContratsRentesPortType_MifMetierSynchroneWsProviderWsContratsRentesPort_Client.java:56)

...

Caused by: java.lang.IllegalArgumentException: 
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseAndSetYear(XMLGregorianCalendarImpl.java:2887)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(XMLGregorianCalendarImpl.java:2773)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:435)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:536)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:586)
	... 35 more

Would you have any idea to avoid this error please ?

Can you try with nillable=“true” attribute

<xsd:element name=“dateEffect” type=“xsd:dateTime” nillable=“true”/>

Oups… it’s of course the first thing i’ve tried yesterday… but…
hum… i’m stupid :? … I’ve forgot to regenerate my JavaCXF client before re-testing…

Thanks for you reply : you make me remind i have to recreate the class with the new attribute :stuck_out_tongue:

Regards

1 Like

Hi,

Now “nillable = true” my first issue is corrected.

Unfortunately I met another problem : my service sometimes returns this king of date : dateEffect = 2015-11-02 00:00:00.0

So, when I call the web service with Java-CXF, this exception is raised… how can I deal with this please ?
(the value comes from ORACLE DATE field, that does not contains day-month-year information)

why this date “2015-11-02 00:00:00.0” date is not accepted from JavaX=CXF please ?


Caused by: javax.xml.bind.UnmarshalException: 2015-12-01 00:00:00.0
 - with linked exception:
[java.lang.IllegalArgumentException: 2015-12-01 00:00:00.0]
	... 39 more
Caused by: java.lang.IllegalArgumentException: 2015-12-01 00:00:00.0
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(XMLGregorianCalendarImpl.java:2823)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:435)
	at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:536)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:586)
	... 35 more

Regards

EDIT :
I’ve found the explanation : my ORACLE Adapter was specyfying the RETURN type as VARCHAR and not as DATE.
So now it’s ok :smiley:

Just to add the xml datetime format is YYYY-MM-DDThh:mm:ss

Good to know you already solved the issue

Thanks for your reply.

Regards