Hello together! Nobody out there with an idea how to solve this problem?
Should I open a new issue at http://jira.codehaus.org/browse/CASTOR ? Any help would be appreciated. Thanks in advance! Michael Schnell > Hello again! > I traced a bit into the code and found the problem seems to be the > "ContainerFieldHandler" - It's not an "ExtendedFieldHandler". > The problem comes up when the first "<path name="/eng/hamburg"/>" gets > unmarshalled. The "UnmarshallHandler" is looking for constructor > arguments and the current "ContainerFieldHandler" is not able to > handle them... > --- UnmarshallHandler.java --- > Arguments args = processConstructorArgs(atts, classDesc); > if ((args.values != null) && (args.values.length > 0)) { > if (handler instanceof ExtendedFieldHandler) { > ExtendedFieldHandler efh = > (ExtendedFieldHandler)handler; > state.object = efh.newInstance(parentState.object, args.values); > } > else { > String err = "constructor arguments can only be " + > "used with an ExtendedFieldHandler."; > throw new SAXException(err); > } > } > ------------------------------ > Any ideas if it's possible to extend "ContainerFieldHandler" to > implement "ExtendedFieldHandler"? > Some help from the Castor "gurus" would be appreciated! > Regards, > Michael >> Hello out there! >> I got a problem unmarshalling the following two classes: >> --- EXCEPTION: --- >> org.xml.sax.SAXException: constructor arguments can only be used with an >> ExtendedFieldHandler. >> --- CLASSES: --- >> public class Path { >> private final String name; >> public Path(final String name) { >> super(); >> this.name = name; >> } >> public final String getName() { >> return name; >> } >> } >> public class Area { >> private final String name; >> private List pathList; >> public Area(final String name) { >> this.name = name; >> } >> public final String getName() { >> return name; >> } >> public final List getPathList() { >> return pathList; >> } >> public final void setPathList(final List list) { >> this.pathList = list; >> } >> } >> --- MAPPING: --- >> <mapping> >> <class name="xml.problem.Path" verify-constructable="false"> >> <field name="name" set-method="%1" get-method="getName" type="string"> >> <bind-xml node="attribute" /> >> </field> >> </class> >> <class name="xml.problem.Area" verify-constructable="false"> >> <field name="name" set-method="%1" get-method="getName" type="string"> >> <bind-xml node="attribute"/> >> </field> >> <field name="pathList" >> type="xml.problem.Path" >> collection="arraylist" >> container="false"> >> <bind-xml name="path-list" node="element" /> >> </field> >> </class> >> </mapping> >> --- XML: --- >> <area name="Hamburg"> >> <path-list> >> <path name="/eng/hamburg"/> >> <path name="/deu/hamburg"/> >> </path-list> >> </area> >> --- VERSIONS: --- >> Castor 1.0.5 >> Java JRE 1.5 >> The problem seems to be "container=false" - If you marshal/unmarshal >> without this attribute everything works fine (but the XML does not >> look as expected)! >> For a full example including a testcase see this ZIP-File: >> http://www.fuin.org/xml-problem.zip >> (I wasn't able to attach the file to this mail because "attachment >> type was not permitted") >> Greetings from (snowless) Germany, >> Michael >> --------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

