Hi

I'm new to Digester and have got simple xml->java processing working based on some examples I found on www.onjava.com and www.javaworld.com.

However, what I fail to see is how I can set a property of a bean if it is of type java.util.Date using a setDate(Date) bean method (xml date should be in RFC822 format)?

I'm not sure this is a Digester problem (since it seems to use BeanUtils internally to do this), but I imagine someone, somewhere has done this using Digester (?).

Anyway, I've been using:
digester.addBeanPropertySetter("pattern/date", "date");
in my code where the property name is date, but this isn't working. The error can be seen below.


I can only assume this has something to do with the fact that the java.util.Date class has no constructor matching a java.lang.String input and needs a DateFormatter to help, but how do you do that here? I haven't tested with other types apart from Strings (Integer, Boolean etc. - do they work as expected?).

Any ideas how to get past this one greatly appreciated?

Regards
Lee Francis Wilhelmsen


Here's the stack trace I get when running the program:

219 [main] DEBUG org.apache.commons.beanutils.ConvertUtils - Convert string 'Wed, 09 Jun 2004 09:19:00 GMT' to class 'java.util.Date'
219 [main] DEBUG org.apache.commons.beanutils.ConvertUtils - Using converter [EMAIL PROTECTED]
219 [main] ERROR org.apache.commons.digester.Digester - End event threw exception
java.lang.IllegalArgumentException: argument type mismatch
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.digester.BeanPropertySetterRule.end(BeanPropertySetterRule.java:244)
at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(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.commons.digester.Digester.parse(Digester.java:1548)
at


etc.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to