Werner, Could you look into that? I'm sorry to keep bugging but I'm really stuck with that.
Thanks again On Thu, May 27, 2010 at 4:46 PM, pablo fernandez <[email protected] > wrote: > Werner, > > Here is the small test case. It uses maven to retrieve castor and junit so > hopefully it would be a no brainer to set up. > > Note that it has a marshalling test that works and the unmarshalling that > throws ClassCastException (seems like it's marshalling to a AnyNode > collection instead of EmailHashEntry). > > Thanks again for your time. > > > > On Thu, May 27, 2010 at 2:33 PM, pablo fernandez < > [email protected]> wrote: > >> Ok, give me a few minutes and I'll do one. >> >> Thanks. >> >> On Thu, May 27, 2010 at 5:23 PM, Werner Guttmann <[email protected]>wrote: >> >>> Actually, in order to be really helpful, we need a small test case that >>> we can use to replay your problem. >>> >>> Werner >>> >>> >>> On 27.05.2010 23:13, pablo fernandez wrote: >>> >>>> Werner, >>>> >>>> Maybe that stack trace is not very helpful... The all the files are the >>>> same >>>> that I copied on the first email, but the mappings to which I added the >>>> fields you told me. >>>> >>>> Please let me know of any additional info or test I might need to >>>> perform in >>>> order to give you more background on this. >>>> >>>> Thanks again for your help >>>> >>>> On Thu, May 27, 2010 at 1:21 PM, pablo fernandez< >>>> [email protected] >>>> >>>>> wrote: >>>>> >>>> >>>> Werner: >>>>> >>>>> Here's the full stack trace: >>>>> >>>>> java.lang.ClassCastException: org.exolab.castor.types.AnyNode >>>>> at >>>>> >>>>> com.osc.services.TestXmlMarshallingService.testShouldUnMarshallEmailHashesXML(TestXmlMarshallingService.java:76) >>>>> 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:592) >>>>> 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 >>>>> >>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) >>>>> at >>>>> >>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) >>>>> at >>>>> >>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) >>>>> at >>>>> >>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) >>>>> at >>>>> >>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) >>>>> at >>>>> >>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) >>>>> >>>>> >>>>> >>>>> On Thu, May 27, 2010 at 3:08 AM, Werner Guttmann<[email protected] >>>>> >wrote: >>>>> >>>>> Hi, >>>>>> >>>>>> without a stack trace, it will be almost impossible to say anything. >>>>>> >>>>>> lG. >>>>>> Werner >>>>>> >>>>>> >>>>>> On 26.05.2010 23:10, pablo fernandez wrote: >>>>>> >>>>>> Werner, >>>>>>> >>>>>>> Thanks a lot for the quick response. I've added those attributes and >>>>>>> the >>>>>>> marshalling goes smoothly. >>>>>>> >>>>>>> Sadly when trying to unmarshall I get this exception: >>>>>>> >>>>>>> java.lang.ClassCastException: com.linkedin.osc.model.EmailHashEntry >>>>>>> >>>>>>> >>>>>>> On Wed, May 26, 2010 at 12:57 PM, Werner Guttmann< >>>>>>> [email protected] >>>>>>> >>>>>>>> wrote: >>>>>>>> >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On 26.05.2010 21:39, pablo fernandez wrote: >>>>>>>> >>>>>>>> Guys, >>>>>>>> >>>>>>>>> >>>>>>>>> I have this Xml: >>>>>>>>> >>>>>>>>> <hashedAddresses> >>>>>>>>> <personAddress index='1'> >>>>>>>>> <hashedAddress>asdfasdf</hashedAddress> >>>>>>>>> <hashedAddress>asdfasdf</hashedAddress> >>>>>>>>> <hashedAddress>asdfasdf</hashedAddress> >>>>>>>>> </personAddres> >>>>>>>>> <personAddress index='2'> >>>>>>>>> <hashedAddress>asdfasdf</hashedAddress> >>>>>>>>> <hashedAddress>asdfasdf</hashedAddress> >>>>>>>>> <hashedAddress>asdfasdf</hashedAddress> >>>>>>>>> </personAddres> >>>>>>>>> </hashedAddresses> >>>>>>>>> >>>>>>>>> That I want to unmarshall in this class: >>>>>>>>> >>>>>>>>> >>>>>>>>> public class EmailHashEntry { >>>>>>>>> >>>>>>>>> private int index; >>>>>>>>> private List<String> hashes; >>>>>>>>> >>>>>>>>> public EmailHashEntry() { >>>>>>>>> >>>>>>>>> } >>>>>>>>> >>>>>>>>> public void setHashes(List<String> hashes) { >>>>>>>>> this.hashes = hashes; >>>>>>>>> } >>>>>>>>> >>>>>>>>> public void setIndex(int index) { >>>>>>>>> this.index = index; >>>>>>>>> } >>>>>>>>> >>>>>>>>> public List<String> getHashes() { >>>>>>>>> return hashes; >>>>>>>>> } >>>>>>>>> >>>>>>>>> public int getIndex() { >>>>>>>>> return index; >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> Using this MAPPING: >>>>>>>>> >>>>>>>>> <?xml version="1.0"?> >>>>>>>>> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version >>>>>>>>> 1.0//EN" >>>>>>>>> " >>>>>>>>> http://castor.org/mapping.dtd"> >>>>>>>>> <mapping> >>>>>>>>> <class name="com.linkedin.osc.model.EmailHashEntry"> >>>>>>>>> >>>>>>>>> <map-to xml="hashedAddresses"/> >>>>>>>>> >>>>>>>>> <field name="index"> >>>>>>>>> <bind-xml name="index" node="attribute" /> >>>>>>>>> </field> >>>>>>>>> >>>>>>>>> <field name="hashes"> >>>>>>>>> <bind-xml name="hashAddress" location="personAddresses" >>>>>>>>> node="element" /> >>>>>>>>> </field> >>>>>>>>> >>>>>>>>> </class> >>>>>>>>> </mapping> >>>>>>>>> >>>>>>>>> >>>>>>>>> PROBLEM: >>>>>>>>> >>>>>>>>> java.lang.IllegalArgumentException: list is not a valid >>>>>>>>> FieldMappingCollectionType >>>>>>>>> >>>>>>>>> I adding "collection='arraylist'" to the mapping and got a NPE. >>>>>>>>> >>>>>>>>> Well, you will need to specify two things in your<field> mapping >>>>>>>>> for >>>>>>>>> >>>>>>>> 'hashes'. Its type: string and that it is a collection, using e.g. >>>>>>>> arraylist >>>>>>>> as default type. >>>>>>>> >>>>>>>> I hope this helps. >>>>>>>> >>>>>>>> Werner >>>>>>>> >>>>>>>> >>>>>>>> Thanks >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>> >>>>> >>>> >> >

