commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: Digester crashes in run mode and succeeds with java debugger
Date Mon, 16 Jul 2012 14:28:51 GMT
Hi Stepan,

I guess that in debug mode, inside your IDE JVM, the invoked method is
public void setFf(String date); OTOH, when running from console, log
clearly show that JVM invokes public void setFf(Date date);

You have two options:

 * drop the Date argument support (less good, IMHO);

 * Rely on Date only and configure BeanUtils doing its job - the
Digester relies on BeanUtils to perform text to Java object
unmarshalling, so for Date type you have to plug the needed converter.
(which is a better/cleaner approach)

Have a look at "Data Type Conversions"[1] to understand how to convert
the extracted XML body text to Date; basically you have
to instantiate a DateConverter[2] and register it via the
ConvertUtils.html#register()[3] method.
The Digester will do the rest.

HTH and don't hesitate on writing back to the ML if needed!
All the best,
-Simo

[1] http://commons.apache.org/beanutils/v1.8.3/apidocs/org/apache/commons/beanutils/package-summary.html#conversion
[2] http://commons.apache.org/beanutils/v1.8.3/apidocs/org/apache/commons/beanutils/converters/DateConverter.html
[3] http://commons.apache.org/beanutils/v1.8.3/apidocs/org/apache/commons/beanutils/ConvertUtils.html#register(org.apache.commons.beanutils.Converter,java.lang.Class)

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/


On Mon, Jul 16, 2012 at 4:11 AM, Stepan Yakovenko <stiv.public@gmail.com> wrote:
> HI
>
> I've got application that uses digerster. There is a bean with two setters:
> public void setFf(String date);
> public void setFf(Date date);
>
> Crash happens here:
>
> org.apache.commons.beanutils.ConversionException: DateConverter does
> not support default String to 'Date' conversion.
>         at org.apache.commons.beanutils.converters.DateTimeConverter.toDate(DateTimeConverter.java:468)
>         at org.apache.commons.beanutils.converters.DateTimeConverter.convertToType(DateTimeConverter.java:343)
>         at org.apache.commons.beanutils.converters.AbstractConverter.convert(AbstractConverter.java:156)
>         at org.apache.commons.beanutils.converters.ConverterFacade.convert(ConverterFacade.java:60)
>         at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:470)
>         at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1014)
>         at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:831)
>         at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:433)
>         at org.apache.commons.digester3.SetPropertiesRule.begin(SetPropertiesRule.java:232)
>         at org.apache.commons.digester3.Digester.startElement(Digester.java:1350)
>         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
>         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
>         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
>         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
>         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>         at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
>         at org.apache.commons.digester3.Digester.parse(Digester.java:1642)
>
> (line numbers may slightly deviate because I've added tracing printlns)
>
> When I try to debug this, no crash happens. Is this a known issue?
> Thanx.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message