XStream ConversionException the second time I parse an XML file

Tekime

New Member
I'm trying to read a TreeMap from an XML file using XStream (I previously created the XML file using XStream too) in my Android application.I simply do this in a static method of a class\[code\]File f = new File(Environment.getExternalStorageDirectory(), "map.xml");XStream xStream = new XStream(new DomDriver());@SuppressWarnings("unchecked") TreeMap<String,Object> map = (TreeMap<String,Object>) xStream.fromXML(f);\[/code\]and then I use the values from the TreeMap with no problems... the first time.The thing is, if I invoke the method for a second time, it doesn't matter if I do it just after the first execution or after a while, I get this: \[code\]05-24 08:33:53.404: E/AndroidRuntime(15543): FATAL EXCEPTION: main05-24 08:33:53.404: E/AndroidRuntime(15543): com.thoughtworks.xstream.converters.ConversionException: null : null05-24 08:33:53.404: E/AndroidRuntime(15543): ---- Debugging information ----05-24 08:33:53.404: E/AndroidRuntime(15543): cause-exception : java.lang.NullPointerException05-24 08:33:53.404: E/AndroidRuntime(15543): cause-message : null05-24 08:33:53.404: E/AndroidRuntime(15543): class : java.util.TreeMap05-24 08:33:53.404: E/AndroidRuntime(15543): required-type : java.util.TreeMap05-24 08:33:53.404: E/AndroidRuntime(15543): converter-type : com.thoughtworks.xstream.converters.collections.TreeMapConverter05-24 08:33:53.404: E/AndroidRuntime(15543): path : /tree-map05-24 08:33:53.404: E/AndroidRuntime(15543): version : 0.005-24 08:33:53.404: E/AndroidRuntime(15543): -------------------------------05-24 08:33:53.404: E/AndroidRuntime(15543): at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)05-24 08:33:53.404: E/AndroidRuntime(15543): at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)[...]05-24 08:33:53.404: E/AndroidRuntime(15543): Caused by: java.lang.NullPointerException05-24 08:33:53.404: E/AndroidRuntime(15543): at java.util.TreeMap.find(TreeMap.java:277)05-24 08:33:53.404: E/AndroidRuntime(15543): at java.util.TreeMap.putInternal(TreeMap.java:240)05-24 08:33:53.404: E/AndroidRuntime(15543): at java.util.TreeMap.put(TreeMap.java:186)05-24 08:33:53.404: E/AndroidRuntime(15543): at java.util.AbstractMap.putAll(AbstractMap.java:381)05-24 08:33:53.404: E/AndroidRuntime(15543): at com.thoughtworks.xstream.converters.collections.TreeMapConverter.populateTreeMap(TreeMapConverter.java:150)[...]\[/code\]with the same file. In fact, if I try to read the file and then pass it to XStream as a String, I get the same exception (but the XML String is created OK).Does anyone know what the cause could be or has experienced the same problem and know how to fix it?Thanks!
 
Back
Top