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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:56:57+00:00 2026-05-24T08:56:57+00:00

I serialize a ArrayList<packageA.Changelog> list to a file and transmitted the file to another

  • 0

I serialize a ArrayList<packageA.Changelog> list to a file and transmitted the file to another system in another machine.

And since it’s a different system that received the file, I don’t have the same packageA.Changelog class, instead is a packageB.Changelog which has exactly same structure but in different package.

And when I use

ArrayList<packageB.Changelog> changelogs = (ArrayList<packageB.Changelog>)ois.readObject();

to read out from the file I got a ClassCastException.

How to avoid this exception? Do I need to create the same package structure in the other system only for receiving the list?

  • 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-24T08:56:58+00:00Added an answer on May 24, 2026 at 8:56 am

    Yes, there are one of the three things you can do.

    1. Create the same class with the same package name

    2. Create an interface(ofcourse again in the same package on both the machines) and ship it on client machines. All your classes can implement this interface even in different packages. For example, your interface can be named Loggable and it should have all the methods declared which are in ChangeLog class right now.

    3. Or finally instead of using the class “ChangeLog” just completely avoid using it and use a HashMap instead which is serializable by default. And you will not have to ship anything to your client(other) machine. You will be able to serialize ArrayList and convert it back to object on other machine.

    All the Classes which implement class Loggable can then cast to that type.
    I hope this helps

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

Sidebar

Related Questions

How can I serialize an ArrayList and Save it in a file?
I am able to serialize an object into a file and then restore it
I was trying to serialize an ArrayList which contains custom objects. I'm serializing it
I'm trying to serialize and deserialize an array list with a object inside: HairBirt
What are different ways in which we can XML serialize multiple objects of same/different
Previously i wrote an app that used reflection to serialize data from json to
There're some library classes that although implement Serializable , fail to serialize correctly. I
I want to serialize the Arraylist of type ArrayList<Class> and the class contains two
I'm trying to serialize a custom class that needs to use multiple elements of
Jackson is throwing a weird exception that I don't know how to fix. I'm

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.