Found the problem. I needed <addDefaults add-properties="false" guess-name="false"/> on all of my mappings, and I needed to add addFoo() methods for my collections. Seems to be working now.
-----Original Message----- From: Sweetland, Jesse [mailto:[EMAIL PROTECTED] Sent: Thursday, August 31, 2006 2:18 PM To: [email protected] Subject: [Betwixt] Unmarshalling Collections I'm getting "Could not create instance of type: java.util.Set" errors when I try to unmarshal an XML document. Here is the stack trace: java.lang.InstantiationException: java.util.Set at java.lang.Class.newInstance0(Class.java:335) at java.lang.Class.newInstance(Class.java:303) at org.apache.commons.betwixt.io.read.ChainedBeanCreatorFactory$2.create(Chaine dBeanCreatorFactory.java:115) at org.apache.commons.betwixt.io.read.BeanCreationList$ChainWorker.create(BeanC reationList.java:128) at org.apache.commons.betwixt.io.read.ChainedBeanCreatorFactory$1.create(Chaine dBeanCreatorFactory.java:62) at org.apache.commons.betwixt.io.read.BeanCreationList$ChainWorker.create(BeanC reationList.java:128) at org.apache.commons.betwixt.io.read.ChainedBeanCreatorFactory$3.create(Chaine dBeanCreatorFactory.java:160) at org.apache.commons.betwixt.io.read.BeanCreationList$ChainWorker.create(BeanC reationList.java:128) at org.apache.commons.betwixt.io.read.BeanCreationList.create(BeanCreationList. java:68) at org.apache.commons.betwixt.io.read.BeanBindAction.createBean(BeanBindAction. java:209) at org.apache.commons.betwixt.io.read.BeanBindAction.begin(BeanBindAction.java: 71) at org.apache.commons.betwixt.io.BeanRuleSet$ActionMappingRule.nextAction(BeanR uleSet.java:286) at org.apache.commons.betwixt.io.BeanRuleSet$ActionMappingRule.begin(BeanRuleSe t.java:255) at org.apache.commons.digester.Digester.startElement(Digester.java:1273) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Ab stractSAXParser.java:533) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanS tartElement(XMLDocumentFragmentScannerImpl.java:878) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragm entContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanD ocument(XMLDocumentFragmentScannerImpl.java:368) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Con figuration.java:834) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Con figuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:14 8) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractS AXParser.java:1242) at org.apache.commons.digester.Digester.parse(Digester.java:1586) at com.talk.domain.betwixt.BetwixtHelper.unmarshal(BetwixtHelper.java:70) at com.talk.domain.betwixt.BetwixtHelper.unmarshal(BetwixtHelper.java:49) at com.talk.domain.betwixt.test.CreateOrderRequestTest.unmarshal(CreateOrderReq uestTest.java:67) at com.talk.domain.betwixt.test.CreateOrderRequestTest.testConsumeCreateOrderRe quest(CreateOrderRequestTest.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRu nner.java:297) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTes tRunner.java:672) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestR unner.java:567) I have an Customer class that contains a java.util.Set of Account classes. The XML, mappings, and classes look like this XML: <cust> <accts> <acct> ... </acct> <acct> ... </acct> </accts> </cust> Customer.betwixt: <?xml version="1.0"?> <info> <element name="cust"> <element name="accts"> <element name="acct" property="accts"/> </element> </element> </info> Customer.java: public class Customer { private Set<Account> _accounts = new LinkedHashSet<Account>(); public Set<Account> getAccounts() { return _accounts; } public void setAccounts(Set<Account> accounts) { _accounts = accounts; } } I have tried to make a custom bean creation chain that will instantiate java.util.LinkedHashSet when the bean type is java.util.Set. The error goes away, but the collection is not populated. I looked through the source code and it looks like isCollective() is never called when reading XML. Is this a bug, or am I doing something wrong? Thanks, - Jesse
