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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:52:38+00:00 2026-05-16T11:52:38+00:00

I understand the theory behind incompatible serialVersionUIDs (i.e. you can discriminate different compilation versions

  • 0

I understand the theory behind incompatible serialVersionUIDs (i.e. you can discriminate different compilation versions of the same class) but I am seeing an issue that I don’t understand and doesn’t fall into the obvious error causes (different compiled version of the same class).

I am testing a serialization/deserialization process. All code is running on one machine, in the same VM, and both serialization and deserialization methods are using the same version of the compiled class. Serialization works fine. The class being serialized is quite complex, contains a number of other classes (java types and UDTs), and contains reference cycles. I haven’t declared my own UID in any class.

This is the code:

public class Test {

    public static void main(String[] args) throws Exception {

        ContextNode context = WorkflowBuilder.getSimpleSequentialContextNode();
        String contextString = BinarySerialization.serializeToString(context);
        ContextNode contextD = BinarySerialization.deserializeFromString(ContextNode.class, contextString);
    }
}

public class BinarySerialization {

    public static synchronized String serializeToString(Object obj) throws Exception {
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(byteStream);
        oos.writeObject(obj);
        oos.close();
        return byteStream.toString();
    }

    public static synchronized <T> T deserializeFromString(Class<T> type, String byteString) throws Exception {
        T object = null;
        ByteArrayInputStream byteStream = new ByteArrayInputStream(byteString.getBytes());
        ObjectInputStream in = new ObjectInputStream(byteStream);
        object = (T)in.readObject();
        in.close();
        return object;
    }
}

I am getting an InvalidClassException (local class incompatible: stream classdesc serialVersionUID = -7189235121689378989, local class serialVersionUID = -7189235121689362093) when deserializing.

What is the underlying issue? And how should I fix it?

Thanks

Edit
I should state the purpose of this. The serialized data will both need to be stored in a sqlite database and sent across the wire to other clients. If String is the wrong format for passing around the serialized data, what should I be using instead that will let me store and pass the data about? Thanks again.

  • 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-05-16T11:52:39+00:00Added an answer on May 16, 2026 at 11:52 am

    First rule: never use String or char[] or Reader or Writer when handling binary data.

    You’re handling binary data and try to put it into a String. Don’t do that, that’s an inherently broken operation.

    Next: the return value of byteStream.toString() doesn’t in any way represent the actual content of the ByteArrayOutputStream. You’ll want to use .getBytes() and pass the byte[] around (remember: treat binary data as binary data and not as a String).

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

Sidebar

Related Questions

I understand the theory behind the factory design pattern now, but can't seem to
I'm no expert, I can't understand the theory in details but it is said
I want to understand the actual theory behind types rather than just learning about
I don't understand the exact algebra and theory behind Haskell's monads. However, when I
I just read some stuff about the theory behind 3d graphics. As I understand
I basically understand the theory behind using the Hough Transform to detect parabolas (i.e.
I'm trying to understand the main concepts of graph theory and the algorithms within
I'm looking at http://hseeberger.wordpress.com/2010/11/25/introduction-to-category-theory-in-scala/ and there's a bit of code that I can't understand
I understand this is an easy question but for some reason this just isn't
I understand I can create an enum like this: public enum MyEnum { ONE(1),

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.