XStream

ClassNotFoundException with writeReplace() classes

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.3
  • Fix Version/s: 1.3.1
  • Component/s: Converters
  • Labels:
    None
  • JDK version and platform:
    Sun 1.5, Mac and Windows

Description

We're using XStream to pass some objects from sever-side back to the client. The server has some internal classes that only exist server-side, but during serialization they're writeReplace()'ed to a common API class. When the xml gets deserialized by XStream client-side it sees something like this:
...
<variable class="com.server.$$InternalClass$$" resolves-to="com.api.NormalClass">
...

The class 'com.server.$$InternalClass$$' doesn't exist client-side, but 'com.api.NormalClass' does. This shouldn't cause a problem, but XStream is still throwing a ClassNotFoundException.

I've attached a zip file containing two files:

  • WriteReplaceTest.java - a test case demonstrating the bug with a contrived example.
  • xstream-1.3-FB10536.patch - a simple patch that fixed this problem for our particular case. I'm hoping there's a better, more general solution.

Activity

Hide
Kevin Bowman added a comment -

Found and patched in 1.1.2 as well. I will attach a 1.1.2 patch file.

Show
Kevin Bowman added a comment - Found and patched in 1.1.2 as well. I will attach a 1.1.2 patch file.
Hide
Kevin Bowman added a comment -

Equivalent patch for 1.1.2

Show
Kevin Bowman added a comment - Equivalent patch for 1.1.2
Hide
Joerg Schaible added a comment -

This issue is fixed now. I did not apply exactly your patch, there have been quite some places where this problem could have been occurred. You might give the head revision a try.

Show
Joerg Schaible added a comment - This issue is fixed now. I did not apply exactly your patch, there have been quite some places where this problem could have been occurred. You might give the head revision a try.
Hide
Joerg Schaible added a comment -

Set correct fix version.

Show
Joerg Schaible added a comment - Set correct fix version.
Hide
Joerg Schaible added a comment -

Fixed for upcoming release.

Show
Joerg Schaible added a comment - Fixed for upcoming release.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: