Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Receiving Serialized Object : Unmatched (Package) Type

 
Ranch Hand
Posts: 409
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Problem: in.readObject() throws a ClassNotFoundException exception because it can't find the class a.package.path.CommandMessage.

I'm sending a serialized object via socket; using writeObject(), readObject(). There are now two versions of the same system that are communicating with one another; one prototype version in which no packages were defined, and a newer version in which classes have been moved into packages.

I am sending a java object (class name: CommandMessage) from the new version with packages to the old version without. The class is defined the same way in both versions, except for the package path.

In other words:
NewSystem: out.writeObject(a.package.path.CommandMessage commandMessage) -> OldSystem: CommandMessage commandMessage = in.readObject() in a system where CommandMessage is in an unnamed package (no package defined).

in.readObj() throws a ClassNotFoundException exception because it can't find the class a.package.path.CommandMessage.

If there's some way to beat this problem, I'd certainly like to know. I'm preparing to Open Source the system. It's a young system and maybe things will be shifted around into new and different packages from time to time for a while.

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Double posted at https://coderanch.com/t/504557/sockets/java/Serialized-Object-readObject-ClassNotFoundException-path
    Bookmark Topic Watch Topic
  • New Topic