Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XMLDecoder doesn't ignore whitespace?  RSS feed

 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted this in the "Servlets" forum, but the post seems to have disappeared, so here it is again (hopefully in the right place this time):

I'm trying to deserialize some Objects stored using an XMLEncoder. Specifically, I have a "MyClassObserver" class that has an "instanceClass" field of type java.lang.Class.
The XMLDecoder can't load classes specified in the xml, because (I think) of whitespace. so, something like this:


will always pop an exception like this:

Notice all the whitespace in the stack trace? I think the ClassLoader (or the XMLDecoder) isn't trimming the class name before trying to load it. Any suggestions?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's significant whitespace you have around the class name, so XML software isn't going to trim it off for you. And if the classloader doesn't trim it (as the stack trace suggests is the case) then it's up to you to trim it yourself. Or if there isn't anything in your code that can get access to it, then don't put the whitespace in the XML in the first place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!