You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ashwini Kondapalli <as...@thomsonreuters.com> on 2015/04/17 14:01:42 UTC

Format of Date Field changed after apache cxf and wildfly upgradation

Issue Description: 
•      The date format in the API response has changed, after the CXF and
Wildfly upgrade. 
•	This issue is affecting all date fields in the response from the API.

Approaches Tried:
•	The suggested approach is to use @XmlJavaTypeAdapter annotation with
custom date time formatter at field level.  This solution has to be applied
at every java.util.Date field in all APIs
•	The ideal solution would be to put global configuration for JAXB to
customize the java.util.Date serializer
•	But so far we couldn’t get a working solution to apply this global
configuration.
As Wildfly 8 is not using JAXB Reference Implementation,the fix we found
also did not help us.

Before Up gradation:
2011-07-16T00:00:00-05:00

After Up gradation:
2011-07-16T00:00:00Z


Some More Info:
which version of the software:apache CXF version 3.0.2
what platform and JDK:jdk1.8.0_31
Any particular container being used - Wildfly8.2.0

Please provide me a solution to this.



--
View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Ashwini Kondapalli <as...@thomsonreuters.com>.
Hi,
This is JAX-WS






--
View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756250.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Sergey Beryozkin <sb...@gmail.com>.
What API is it, JAX-WS or JAX-RS ?

Sergey


On 17/04/15 13:01, Ashwini Kondapalli wrote:
> Issue Description:
> •      The date format in the API response has changed, after the CXF and
> Wildfly upgrade.
> •	This issue is affecting all date fields in the response from the API.
>
> Approaches Tried:
> •	The suggested approach is to use @XmlJavaTypeAdapter annotation with
> custom date time formatter at field level.  This solution has to be applied
> at every java.util.Date field in all APIs
> •	The ideal solution would be to put global configuration for JAXB to
> customize the java.util.Date serializer
> •	But so far we couldn’t get a working solution to apply this global
> configuration.
> As Wildfly 8 is not using JAXB Reference Implementation,the fix we found
> also did not help us.
>
> Before Up gradation:
> 2011-07-16T00:00:00-05:00
>
> After Up gradation:
> 2011-07-16T00:00:00Z
>
>
> Some More Info:
> which version of the software:apache CXF version 3.0.2
> what platform and JDK:jdk1.8.0_31
> Any particular container being used - Wildfly8.2.0
>
> Please provide me a solution to this.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Ashwini Kondapalli <as...@thomsonreuters.com>.
cxf-samples.rar
<http://cxf.547215.n5.nabble.com/file/n5756557/cxf-samples.rar>  
I have also tried the option of adding the jaxb:globalbindings
Added:
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:jxb="http://java.sun.com/xml/ns/jaxb">

    <jxb:globalBindings>
        <jxb:javaType name="java.util.Date" xmlType="xs:date"
                      parseMethod="demo.spring.DateAdapter.unmarshall"
                      printMethod="demo.spring.DateAdapter.marshall"/>
                      
        <jxb:javaType name="java.util.DateTime" xmlType="xs:dateTime"
                      parseMethod="demo.spring.DateAdapter.unmarshall"
                      printMethod="demo.spring.DateAdapter.marshall"/>
    </jxb:globalBindings>

</jxb:bindings>
And The DateAdapter.java file too.
But still the same ,

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getEntityDataResponse xmlns:ns2="http://spring.demo/">
         <return>
            *<date>2015-04-27T07:59:44.314Z</date>*
         </return>
      </ns2:getEntityDataResponse>
   </soap:Body>
</soap:Envelope>
Attached is the source code, please look into it and let me know if you have
questions.

Thanks
Ashwini K



--
View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756557.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Alessio Soldano <as...@redhat.com>.
OK, will try to reproduce this week and let you know.

Alessio

On 24/04/15 07:42, Ashwini Kondapalli wrote:
> Hi,
> Replicator code link is attached below.
> Please deploy this is in wildfly 8.2.0 and link wil be
> http://localhost:8080/Test/services/
> 1. Run the SOAP request in (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
> Timezone then the date is
> *
> <date>2015-04-24T10:56:28.220+05:30</date>*
>
> 2. Run the SOAP request in (UTC) Coordinated Universal Time then the
>
> *<date>2015-04-24T05:16:04.657Z</date>
> *
> So then I have used the DateAdapter.java file to handle this but we are able
> to apply it at field level or package level only. Just need a solution at
> the global level so that we can fix it.
> This is very urgent fix as we have to address all the API's and also the csv
> responses.
> Please Note: I was unable to upload it here, because the war was too large.
> I have uploaded in my google drive. Please see the below link:
> https://drive.google.com/file/d/0By62-Y40DSrJeDhNX3dwNWF6aEE/view?usp=sharing&invite=CO3U6PsH
>
> Please look into it.
>
>
> If you require anything else please let me know??
>
> Thanks
> Ashwini K
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756493.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Alessio Soldano
Web Service Lead, JBoss


Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Alessio Soldano <as...@redhat.com>.
On 30/04/15 12:53, Alessio Soldano wrote:
> Hi,
> your reproducer didn't help that much (it does not even deploy on 
> WildFly 8.2.0.Final ;-)), however I've created a similar scenario 
> testcase, applied an adapter for formatting the date and it all worked 
> as expected. The sources are committed in JBossWS project, see 
> http://anonsvn.jboss.org/repos/jbossws/stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/date/
Moreover, generally speaking, if you're concerned about the timezone 
used in the date exchanged in soap messages, you should likely use 
Calendar / XMLGregoriaCalendar and explicitly set it. If you don't want 
the timezone to be specified at all, instead, the above solution with 
adapter is most likely the proper approach.

Alessio

-- 
Alessio Soldano
Web Service Lead, JBoss


Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Alessio Soldano <as...@redhat.com>.
Hi,
your reproducer didn't help that much (it does not even deploy on 
WildFly 8.2.0.Final ;-)), however I've created a similar scenario 
testcase, applied an adapter for formatting the date and it all worked 
as expected. The sources are committed in JBossWS project, see 
http://anonsvn.jboss.org/repos/jbossws/stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/date/

Cheers
Alessio

On 24/04/15 07:42, Ashwini Kondapalli wrote:
> Hi,
> Replicator code link is attached below.
> Please deploy this is in wildfly 8.2.0 and link wil be
> http://localhost:8080/Test/services/
> 1. Run the SOAP request in (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
> Timezone then the date is
> *
> <date>2015-04-24T10:56:28.220+05:30</date>*
>
> 2. Run the SOAP request in (UTC) Coordinated Universal Time then the
>
> *<date>2015-04-24T05:16:04.657Z</date>
> *
> So then I have used the DateAdapter.java file to handle this but we are able
> to apply it at field level or package level only. Just need a solution at
> the global level so that we can fix it.
> This is very urgent fix as we have to address all the API's and also the csv
> responses.
> Please Note: I was unable to upload it here, because the war was too large.
> I have uploaded in my google drive. Please see the below link:
> https://drive.google.com/file/d/0By62-Y40DSrJeDhNX3dwNWF6aEE/view?usp=sharing&invite=CO3U6PsH
>
> Please look into it.
>
>
> If you require anything else please let me know??
>
> Thanks
> Ashwini K
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756493.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Alessio Soldano
Web Service Lead, JBoss


Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Ashwini Kondapalli <as...@thomsonreuters.com>.
Hi,
Replicator code link is attached below.
Please deploy this is in wildfly 8.2.0 and link wil be
http://localhost:8080/Test/services/
1. Run the SOAP request in (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
Timezone then the date is 
*
<date>2015-04-24T10:56:28.220+05:30</date>*

2. Run the SOAP request in (UTC) Coordinated Universal Time then the 

*<date>2015-04-24T05:16:04.657Z</date>
*
So then I have used the DateAdapter.java file to handle this but we are able
to apply it at field level or package level only. Just need a solution at
the global level so that we can fix it.
This is very urgent fix as we have to address all the API's and also the csv
responses.
Please Note: I was unable to upload it here, because the war was too large.
I have uploaded in my google drive. Please see the below link:
https://drive.google.com/file/d/0By62-Y40DSrJeDhNX3dwNWF6aEE/view?usp=sharing&invite=CO3U6PsH

Please look into it.


If you require anything else please let me know??

Thanks
Ashwini K



--
View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756493.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Alessio Soldano <as...@redhat.com>.
How about all the other questions in my last message?

Alessio

On 20/04/15 15:28, Ashwini Kondapalli wrote:
> yes here it is,
>
> package com.thomsonreuters.ls.api.util;
>
> import java.text.SimpleDateFormat;
> import java.util.Date;
>
> import javax.xml.bind.annotation.adapters.XmlAdapter;
>
> public class DateAdapter extends XmlAdapter<String, Date> {
>
>      private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
> HH:mm:ss");
>
>      @Override
>      public String marshal(Date v) throws Exception {
>          return dateFormat.format(v);
>      }
>
>      @Override
>      public Date unmarshal(String v) throws Exception {
>          return dateFormat.parse(v);
>      }
>
> }
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756288.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Alessio Soldano
Web Service Lead, JBoss


Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Ashwini Kondapalli <as...@thomsonreuters.com>.
yes here it is,

package com.thomsonreuters.ls.api.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class DateAdapter extends XmlAdapter<String, Date> {

    private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");

    @Override
    public String marshal(Date v) throws Exception {
        return dateFormat.format(v);
    }

    @Override
    public Date unmarshal(String v) throws Exception {
        return dateFormat.parse(v);
    }

}



--
View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756288.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Alessio Soldano <as...@redhat.com>.
On 20/04/15 13:26, Ashwini Kondapalli wrote:
> We had done upgrade from jboss 5.1.0 to Wildfly8.2.0,
JBoss AS 5.1.0 was not using an Apache CXF based stack by default; did 
you install JBossWS-CXF (the JBossWS integration with Apache CXF) 
3.1.2.GA on it?
This is important to understand if we're somehow talking about a 
different behavior in 2 different CXF versions or not (in which case 
this mailing list is not likely the best place to talk about the topic 
and we'd better move to the JBoss forums).

> but here in wildfly we
> see that Wildfly 8 is not using JAXB Reference Implementation.
https://github.com/jboss/jaxb/commits/2.2.5.jboss-2 this is list of 
differences between the JBoss version of JAXB 2.2.5 in WildFly 8.2.0 and 
the vanilla JAXB 2.2.5.

> Trials done by me:
> *Approach1*:
> Added package-info.java file and also the DateAdapter.java to the project:
> @XmlJavaTypeAdapters({
> 	@XmlJavaTypeAdapter(value=XXX.util.DateAdapter.class,
> type=java.util.Date.class) })
>   package TOPLEVEL-PACKAGE;
> import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
> import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
>
> *Approach2:*
> Tried adding new file jaxb-binding.xml with the below content to my project
> resources folder:
> <?xml version="1.0" encoding="UTF-8"?>
>
>   <jxb:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>            xmlns:xs="http://www.w3.org/2001/XMLSchema"
>            xmlns:jxb="http://java.sun.com/xml/ns/jaxb">
> <jxb:globalBindings>
>          <jxb:javaType name="java.util.Date" xmlType="xs:date"
>          			
> parseMethod="com.thomsonreuters.ls.api.util.DateAdapter.unmarshall"
>                       
> printMethod="com.thomsonreuters.ls.api.util.DateAdapter.marshall"/>
> </jxb:globalBindings>
> </jxb:bindings>
> Both these approaches did not help  me.
And what is happening? Is the DateAdapter ignored? Can you share the 
code of the adapter somewhere?

Alessio

-- 
Alessio Soldano
Web Service Lead, JBoss


Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Ashwini Kondapalli <as...@thomsonreuters.com>.
Hi,
We had done upgrade from jboss 5.1.0 to Wildfly8.2.0,but here in wildfly we
see that Wildfly 8 is not using JAXB Reference Implementation. 
Trials done by me:
*Approach1*:
Added package-info.java file and also the DateAdapter.java to the project:
@XmlJavaTypeAdapters({     
	@XmlJavaTypeAdapter(value=XXX.util.DateAdapter.class,
type=java.util.Date.class) })
 package TOPLEVEL-PACKAGE;   
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;

*Approach2:*
Tried adding new file jaxb-binding.xml with the below content to my project
resources folder:
<?xml version="1.0" encoding="UTF-8"?>

 <jxb:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:jxb="http://java.sun.com/xml/ns/jaxb">
<jxb:globalBindings>  
        <jxb:javaType name="java.util.Date" xmlType="xs:date"
        			 
parseMethod="com.thomsonreuters.ls.api.util.DateAdapter.unmarshall"
                     
printMethod="com.thomsonreuters.ls.api.util.DateAdapter.marshall"/>
</jxb:globalBindings>
</jxb:bindings>
Both these approaches did not help  me.


Thanks
Ashwini K



--
View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208p5756268.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Format of Date Field changed after apache cxf and wildfly upgradation

Posted by Alessio Soldano <as...@redhat.com>.
Any chance you can provide more details (perhaps a reproducer) ?
You're mentioning an upgrade, which version of WildFly have you been 
moving from?
Which fix did not work as a consequence of the JAXB version shipped in 
WildFly (which technically speaking is the RI plus few minor changes) ?

Alessio

On 17/04/15 14:01, Ashwini Kondapalli wrote:
> Issue Description:
> •      The date format in the API response has changed, after the CXF and
> Wildfly upgrade.
> •	This issue is affecting all date fields in the response from the API.
>
> Approaches Tried:
> •	The suggested approach is to use @XmlJavaTypeAdapter annotation with
> custom date time formatter at field level.  This solution has to be applied
> at every java.util.Date field in all APIs
> •	The ideal solution would be to put global configuration for JAXB to
> customize the java.util.Date serializer
> •	But so far we couldn’t get a working solution to apply this global
> configuration.
> As Wildfly 8 is not using JAXB Reference Implementation,the fix we found
> also did not help us.
>
> Before Up gradation:
> 2011-07-16T00:00:00-05:00
>
> After Up gradation:
> 2011-07-16T00:00:00Z
>
>
> Some More Info:
> which version of the software:apache CXF version 3.0.2
> what platform and JDK:jdk1.8.0_31
> Any particular container being used - Wildfly8.2.0
>
> Please provide me a solution to this.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Format-of-Date-Field-changed-after-apache-cxf-and-wildfly-upgradation-tp5756208.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Alessio Soldano
Web Service Lead, JBoss