Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:39:08+00:00 2026-06-05T01:39:08+00:00

I’m trying to read a TreeMap from an XML file using XStream (I previously

  • 0

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

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);

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:

05-24 08:33:53.404: E/AndroidRuntime(15543): FATAL EXCEPTION: main
05-24 08:33:53.404: E/AndroidRuntime(15543): com.thoughtworks.xstream.converters.ConversionException: null : null
05-24 08:33:53.404: E/AndroidRuntime(15543): ---- Debugging information ----
05-24 08:33:53.404: E/AndroidRuntime(15543): cause-exception     : java.lang.NullPointerException
05-24 08:33:53.404: E/AndroidRuntime(15543): cause-message       : null
05-24 08:33:53.404: E/AndroidRuntime(15543): class               : java.util.TreeMap
05-24 08:33:53.404: E/AndroidRuntime(15543): required-type       : java.util.TreeMap
05-24 08:33:53.404: E/AndroidRuntime(15543): converter-type      : com.thoughtworks.xstream.converters.collections.TreeMapConverter
05-24 08:33:53.404: E/AndroidRuntime(15543): path                : /tree-map
05-24 08:33:53.404: E/AndroidRuntime(15543): version             : 0.0
05-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.NullPointerException
05-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)
[...]

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:39:10+00:00Added an answer on June 5, 2026 at 1:39 am

    Ok, it seemed to be a problem with TreeMap and Android… using HashMap now, works OK 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am using parse_ini_file to read the contents of a file however it is
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an XML file, the creators of it stuck in a bunch social
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.