ObjectInputStream readObject(): ClassNotFoundException

前端 未结 2 1312
醉话见心
醉话见心 2021-01-20 03:20

In both client and server classes, I have an exact same inner class called Data. This Data object is being sent from the server using:

ObjectOutputStream out         


        
2条回答
  •  遇见更好的自我
    2021-01-20 03:56

    When you use some class in two different JVMs, and you are marshalling/unmarshalling the class then the class should be exported to a common library and shared between both server and client. Having different class wont work any time.

    What you are trying to do is marshall TCPServer$Data and unmarshall as TCPClient$Data. That is incompatible.

提交回复
热议问题