That's what I thought initially, but then I started to think that the problem might be solely related to your usage of locations, and not to the way the Unmarshaller is instantiated. Well ... looks like the first advice has been correct .. ;-).
Thanks for the feedback. Werner S. Sharif wrote: > Actually i think I figured this out. All of my > various input xml's that I want to unmarshall to > different java objects have a common structure; they > are all wrapped insides of a root <Document> tag. So > when Castor wants to unmarshall a given xml it looks > in the mapping file and grabs the first class occuring > with a root <Document> tag. In this case it grabbed > the wrong one. Then when it looked for the next child > tag <DVPCRITERIAINPUT_LIST> of the root <Document> > tag, it did not find it inside of that class that it > grabbed. As a result, it threw an exception. This is > my speculation on what happend. > > I modified my code to pass in to the Unmarshaller > constructor the class type of the correct class that I > want to unmarshall to: > > > unmarshaller = new > Unmarshaller(RunDvpRequestVO.class); > unmarshaller.setMapping(mapping); > > > And now the code works even when the mapping file is > not in the correct order. > > -Saladin > > --- Werner Guttmann <[EMAIL PROTECTED]> wrote: > >> Actually, my last message might be completely >> ignorable. Can you please >> open a new issue at >> >> http://jira.codehaus.org/browse/CASTOR >> >> and attach all relevant files. Somehow the bahaviour >> you are seeing >> seems 'odd' to me .... >> >> Werner >> >> S. Sharif wrote: >>> Hi, >>> I get the following error >>> >>> unable to find FieldDescriptor for >>> 'DVPCRITERIAINPUT_LIST' in ClassDescriptor of >>> Document{File: [not available]; line: 3 column: >> 26} >>> at >>> > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:740) >>> at >>> > org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:596) >>> ..... etc. >>> >>> >>> when I execute the following piece of code: >>> >>> >>> // load castor mapping file >>> Mapping map = new Mapping(); >>> map.loadMapping(mappingPath); >>> unmarshaller = new Unmarshaller(map); >>> >>> // Unmarshall the input xml into a value object >>> RunDvpRequestVO runDvpRequest = (RunDvpRequestVO) >>> unmarshaller.unmarshal(new >>> FileReader(inputXmlFilePath)); >>> >>> >>> >>> with the following input xml: >>> >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <Document> >>> <DVPCRITERIAINPUT_LIST> >>> <DVPCRITERIAINPUT> >>> <DVPCRITERIAID>1</DVPCRITERIAID> >>> </DVPCRITERIAINPUT> >>> </DVPCRITERIAINPUT_LIST> >>> >>> [ ... remaining xml was omitted for brevity ...] >>> >>> </Document> >>> >>> >>> >>> This is the Castor xml mapping file that I used: >>> >>> >>> <mapping> >>> <description>Description of the >>> mapping</description> >>> >>> <!-- ----- ----- 1st Group of Classes ----- >> ----- >>> --> >>> >>> <class >>> > name="com.testcom.nget.valueobject.databinding.response.RunDvpResponseVO" >>> auto-complete="true"> >>> <map-to xml="Document"/> >>> <field name="response" >>> > type="com.testcom.nget.valueobject.databinding.response.ResponseVO"> >>> <bind-xml name="RESPONSE" >>> location="RESPONSE_LIST"/> >>> </field> >>> <field name="dvpRunId"> >>> <bind-xml name="DVPRUNID" >>> location="DVPRUN_LIST/DVPRUN"/> >>> </field> >>> </class> >>> >>> >>> [ ... more xml was omitted for brevity ...] >>> >>> >>> <!-- ----- ----- 2nd Group of Classes ----- >> ----- >>> --> >>> >>> <class >>> > name="com.testcom.nget.valueobject.databinding.RunDvpRequest.RunDvpRequestVO" >>> auto-complete="true"> >>> <map-to xml="Document"/> >>> <field name="logins" collection="hashtable" > >>> <bind-xml name="LOGIN_LIST"> >>> <class >>> name="org.exolab.castor.mapping.MapItem"> >>> <field name="key" type="java.lang.String"> >>> <bind-xml name="filter" node="attribute"/> >>> </field> >>> <field name="value" >>> > type="com.testcom.nget.valueobject.databinding.RunDvpRequest.LoginVO"> >>> <bind-xml name="LOGIN"/> >>> </field> >>> </class> >>> </bind-xml> >>> </field> >>> <field name="dvpCriteriaId"> >>> <bind-xml name="DVPCRITERIAID" >>> >> location="DVPCRITERIAINPUT_LIST/DVPCRITERIAINPUT"/> >>> </field> >>> </class> >>> >>> [ ... more xml was omitted for brevity ...] >>> >>> >>> </mapping> >>> >>> >>> >>> What is strange is that when I reorder the classes >> in >>> the xml mapping file, by moving the 1st group of >>> classes below the 2nd group of class in the >> mapping >>> file above, the error goes away. Is there a way >> for >>> me to avoid getting this error programmatically >> rather >>> than having to re-order the mapping file? >>> >>> I am still in the process of adding more classes >> to >>> the same mapping file, and I am concerned that as >> the >>> mapping file grows big, at some point I may no >> longer >>> be able to reorder the mapping file in the right >>> order, in order for the code to work. >>> >>> Any help or suggestions is very much appreciated. >>> >>> Thanks. >>> >>> >>> > ********************************************************** >>> * Saladin Sharif >>> * e-mail: [EMAIL PROTECTED] >>> * Visit homepage @ >> http://gaia.ecs.csus.edu/~sharifs > ********************************************************** >>> >>> >>> > ____________________________________________________________________________________ >>> The fish are biting. >>> Get more visitors on your site using Yahoo! Search >> Marketing. > http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php >>> > --------------------------------------------------------------------- >>> To unsubscribe from this list please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >> >> > --------------------------------------------------------------------- >> To unsubscribe from this list please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > > > > ____________________________________________________________________________________ > Food fight? Enjoy some healthy debate > in the Yahoo! Answers Food & Drink Q&A. > http://answers.yahoo.com/dir/?link=list&sid=396545367 > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

