[mule-user] xml-to-object-transformer

2 views
Skip to first unread message

patricksan

unread,
Jun 9, 2009, 10:04:45 AM6/9/09
to us...@mule.codehaus.org

Dear All,

I have this XML:
....
....
<createDate>2009-05-19T07:40:00</createDate>
....
....

When I try to convert to the object using xml-to-object-transformer I got
this exception:
oot Exception stack trace:
com.thoughtworks.xstream.converters.ConversionException: Cannot parse date
2009-05-19T07:40:00
---- Debugging information ----
class : com.vangenechten.system.edi.model.DelForHeader
required-type : java.util.Date
path :
/com.vangenechten.system.edi.model.DelForHeader/createDate
line number : 6
-------------------------------
at
com.thoughtworks.xstream.converters.basic.DateConverter.fromString(DateConverter.java:52)
at
com.thoughtworks.xstream.converters.SingleValueConverterWrapper.fromString(SingleValueConverterWrapper.java:31)
at
com.thoughtworks.xstream.converters.SingleValueConverterWrapper.unmarshal(SingleValueConverterWrapper.java:39)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at
com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)

Is there a way to set the format or locale to avoid this problem?

Thank you,
Patrick Santana

--
View this message in context: http://www.nabble.com/xml-to-object-transformer-tp23943557p23943557.html
Sent from the Mule - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


dhenton9000

unread,
Jun 9, 2009, 11:12:50 AM6/9/09
to us...@mule.codehaus.org

I handled this by creating my own xmltoobject transformer that is a simple
override of the OOTB transformer.

The xstream site talks about the joda classes which is a jar file full of
date time code available on sourceforge.

ISO8601GregorianCalendarConverter provides a huge collection of formats for
translation, but it isn't active by default.

HTH


import org.mule.api.transformer.TransformerException;
import org.mule.module.xml.transformer.XmlToObject;
import
com.thoughtworks.xstream.converters.extended.ISO8601GregorianCalendarConverter;

/**
* You must have the joda jar file in the classpath for this to work.
* @author dyh
*
*/
public class SoapMessageConverter extends XmlToObject {

public SoapMessageConverter()
{
super();
try {
getXStream().registerConverter(new ISO8601GregorianCalendarConverter());
} catch (TransformerException e) {
throw new RuntimeException("unable to get xstream " +
"in converter constructor "+e.getMessage());
}

}

}

--
View this message in context: http://www.nabble.com/xml-to-object-transformer-tp23943557p23944862.html

Andrew Perepelytsya

unread,
Jun 9, 2009, 11:46:26 AM6/9/09
to us...@mule.codehaus.org

Hi, later Mule versions allow for better customization of this transformer. Anyway, could you please file a jira so we can consider this library for inclusion in the OOTB distribution?

Thanks!
Andrew

} } } patricksan wrote: > > Dear All, > > I have this XML: > .... > .... > <createDa...

Sent from the Mule - User mailing list archive at Nabble.com. ------------------------------------...

patricksan

unread,
Jun 10, 2009, 3:25:06 AM6/10/09
to us...@mule.codehaus.org

I just did it: http://www.mulesource.org/jira/browse/MULE-4394


Andrew Perepelytsya wrote:
>
> Hi, later Mule versions allow for better customization of this
> transformer.
> Anyway, could you please file a jira so we can consider this library for
> inclusion in the OOTB distribution?
>
> Thanks!
> Andrew
>

--
View this message in context: http://www.nabble.com/xml-to-object-transformer-tp23943557p23957095.html


Sent from the Mule - User mailing list archive at Nabble.com.

patricksan

unread,
Jun 10, 2009, 5:03:37 AM6/10/09
to us...@mule.codehaus.org

For future reference. If I use

getXStream().registerConverter(new ISO8601GregorianCalendarConverter()

it does not work. It has the same exception. So I changed it to

getXStream().registerConverter(new ISO8601DateConverter());

and it works.


Thank you all,
Patrick

--
View this message in context: http://www.nabble.com/xml-to-object-transformer-tp23943557p23957834.html

Reply all
Reply to author
Forward
0 new messages