views:

274

answers:

3

I have a client and server application that transfer message using serialization over TCP. I got the following error when deserializing an object:

Any ideas to the cause or possible next steps in analyzing this problem?

java.io.StreamCorruptedException: invalid stream header: 383D4649
    at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
    at java.io.ObjectInputStream.<init>(Unknown Source)
    at com.aqua.NmsApi.ResiliantTCPServer$ServerThread.run(ResiliantTCPServer.java:248)
    at java.lang.Thread.run(Unknown Source)
+1  A: 

There's something wrong with the magic number at the head of the serialized data. You're probably going to need to capture the serialized data and look it over yourself to start with. That ascii stream is '8=FI'.

Charlie Martin
these are remote logs of the server process. the user restarted the server and it started working. but i'm still analyzing the cause.
richs
It's not too improbable then that there was a transient comms issue. You should add exception handling around the original exception location, see if you can capture more data.
Charlie Martin
A: 

There are two possible reasons for that:

  • The stream has actually been corrupted (i.e. what you are reading is different from what you wrote at the other end). In that case you should write in a local file each contents (emitted and received), and compare them.

  • The magic numbers required by the implementation(s) of ObjectInputStream you are using at are different at either end, for instance because you are using different versions of the Java base packages. Those constants are declared in ObjectStreamConstants, you should check them.

Varkhan
A: 

are you using exactly one ObjectInput/OutputStream per socket Input/OutputStream? recreating these on the same input/output stream is a common cause of such an error.

james