I have submitted a bug report with a simple junit test case. http://jira.codehaus.org/browse/CASTOR-2808
Thank you! / Fredrik --- Den tors 2009-08-06 skrev Werner Guttmann <[email protected]>: Från: Werner Guttmann <[email protected]> Ämne: Re: [castor-user] [XML] Castor 1.2 Unmarshal fails for vector containing long[] Till: [email protected] Datum: torsdag 6 augusti 2009 14.28 Fredrik, how about opening a new issue at http://jira.codehaus.org/browse/CASTOR where you attach a minimal test case so that we can reproduce the problem ? Regards Werner Fredrik Johansson wrote: > Hi Werner! > > I am a bit confused about that too. I did not write this code myself, I just > try to fix the bug. > I tried to change "type" in different ways, but I could not make it work. I > tried e.g to set type="long[]". > Castor seems to understand that the runtime type is a long[]. The marshaling > works fine and the values in the XML file are surrounded by <long> </long> > tags."other" corresponds to java.lang.Object so I guess its a way of making > it work irrespective of what is stored in the vector (only it does not work). > However, storing arrays of long values is sufficient for my application. > > Regards > > / Fredrik > > --- Den tors 2009-08-06 skrev Werner Guttmann <[email protected]>: > > Från: Werner Guttmann <[email protected]> > Ämne: Re: [castor-user] [XML] Castor 1.2 Unmarshal fails for vector > containing long[] > Till: [email protected] > Datum: torsdag 6 augusti 2009 11.18 > > Hi Fredrik, > > looking at this, I wonder why you are using a type of "other" in your > mapping ? Any hints ? > > Regards > Werner > > Fredrik Johansson wrote: >> Hi! >> >> I have a problem with unmarshal. I use a vector (old legacy code) containing >> a long[]. The array contains x and y coordinates. Marshaling works fine, but >> unmarshal fails. Any help is much appreciated. >> >> I use the following mapping to marshall/unmarshall >> >> <field name="m_marks" type="other" collection="vector" >> get-method="getMarks" set-method="setMarks" /> >> >> The java class contains the following attributes and methods >> >> private Vector m_marks; >> >> public Vector getMarks() >> public void setMarks(Vector marks) >> >> public long[] getMarksArray() >> public void setMarksArray(long[]) >> >> Marshalling works fine and the following XML is generated >> >> >> <m_marks >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>xsi:type="java:[J"> >> <long>6783933</long> >> <long>9999988</long> >> </m_marks> >> <m_marks >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>xsi:type="java:[J"> >> <long>2332333</long> >> <long>6767777</long> >> </m_marks> >> >> <m_marks >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>xsi:type="java:[J"> >> <long>0</long> >> <long>0</long> >> </m_marks> >> <m_marks >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>xsi:type="java:[J"> >> <long>0</long> >> <long>0</long> >> </m_marks> >> >> When I try to unmarshal the file I get the following exception (most >> interesting >> part of stack trace shown) >> >> org.exolab.castor.xml.MarshalException: [J{File: [not available]; line: 45; >> column: 86} >> at >>org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:761) >> at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:727) >> at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616) >> >> >> >> Caused by: java.lang.ClassNotFoundException: [J >> at java.net.URLClassLoader$1.run(URLClassLoader.java:200) >> at java.security.AccessController.doPrivileged(Native Method) >> at java.net.URLClassLoader.findClass(URLClassLoader.java:188) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:307) >> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) >> at >> java.lang.ClassLoader.loadClass(ClassLoader.java:252) >> at >>org.exolab.castor.xml.UnmarshalHandler.loadClass(UnmarshalHandler.java:3604) >> at >>org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:2161) >> at >>org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1418) >> at >>org.apache.xerces.parsers.SAXParser.startElement(SAXParser...java:1376) >> at >>org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1197) >> at >>org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1862) >> at >>org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1238) >> at >>org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) >> at >> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035) >> at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:715) >> >> >> >> Anything wrong with my mapping? Any ideas how to solve this? I could replace >> the array with a Position class containing the coordinates, but I would >> prefer not to change the file format. >> >> Best regards >> >> / Fredrik Johansson >> >> >> >> >> >> __________________________________________________________ >> Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling. >> Sök och jämför priser hos Kelkoo. >> http://www.kelkoo.se/c-100015813-bredband.html?partnerId=96914325 > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > > > ___________________________________________________ > Sök efter kärleken! > Hitta din tvillingsjäl på Yahoo! Dejting: > http://ad..doubleclick.net/clk;185753627;24584539;x?http://se.meetic.yahoo.net/index.php?mtcmk=148783 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email __________________________________________________________ Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo. http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014

