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 8729229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:47:45+00:00 2026-06-13T08:47:45+00:00

I use XStream with DomDriver to serialize and deserialize a DefaultStyledDocument object, so I

  • 0

I use XStream with DomDriver to serialize and deserialize a DefaultStyledDocument object, so I save and retrieve it’s state in a database. The serialization part goes well, but when it tries to deserialize, an excetption is thrown:

[Fatal Error] :92:51: Character reference "&#
Exception in thread "AWT-EventQueue-0" com.thoughtworks.xstream.io.StreamException: : Character reference "&#

I believe &# is the space character in the document.

I even tried using a different driver like: StaxDriver, JsonHierarchicalStreamDriver and JettisonMappedXmlDriver, but had no luck.

What am I doing wrong here?

Here’s my code:

DefaultStyledDocument doc = new DefaultStyledDocument();
//initialize doc
XStream xmlstream = new XStream(new StaxDriver());
String xml = xmlstream.toXML(doc);
//save 'xml' in database

//select from database
DefaultStyledDocument document = (defaultStyledDocument) xmlstream.fromXML(result.getString(1));
//this is where the exception is thrown.

EDIT
Actually &# is not a space character, because now i see that the space character is represented by ” “. &# seems to be the not edited (empty) part of the document. It’s really annoying that is serializes it, but doesn’t deserialize it back.

  • 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-13T08:47:46+00:00Added an answer on June 13, 2026 at 8:47 am

    Given the XML snippet you provided in the comments above, the error message is correct – there are certain characters that are forbidden from appearing in XML 1.0 documents by the spec even as character references, and U+0000 is one of these characters. Thus � is not well-formed XML and the parser is right to reject it. The serializer is clearly being more lenient in allowing it to be written.

    I would suggest you explore other non-XML ways to represent this data in your database, maybe as a BLOB (using Java object serialization) or similar.

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

Sidebar

Related Questions

I use XStream to serialize an object A implementing an interface : interface MyInterface
I use XStream to write an object in a xml file . Then I
I'm implementing a save/load in NetBeans platform application. And I'm using XStream to serialize
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Can I safely use XStream to process XML coming from outside of my system
I'm looking for a way to serialize Java objects into XML for use by
I'm trying to use XStream to import large XML files (~ 1 GB). I
This code: println(new XStream.toXML(List(1,2,3))) produces this XML: <scala.coloncolon serialization=custom> <unserializable-parents/> <scala.coloncolon> <int>1</int> <int>2</int> <int>3</int>
I have got the XStream package by apt-get install libxstream-java. I'd like to use
One of my class has to serialize huge numbers of instances and using Xstream,

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.