Deserialize an Object in the JMS message
Has anyone tried deserializing a JMS Object message from IBM MQ Visual Edit? I need to decipher an object that was send as a JMS message through MQ. I saved the message to a file and tried to read it using ObjectInputStream as follows:
ObjectInputStream objectStream = new ObjectInputStream(new DataInputStream(new FileInputStream("PATH TO THE FILE"))); SomeObject result = ((SomeObject)objectStream.readObject());
But I get an error:
java.io.StreamCorruptedException: invalid stream header: 52464820 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:794) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:291) at com.railinc.emis.transaction.model.DeserializerClass.main(DeserializerClass.java:14)
I went an researched a little bit on this and found the same classes that were used to serialize should be used for deserializing.
If someone has tried this before, please let me know your experience with it.
I don't know IBM MQ Visual Edit but if it has a feature to save an ObjectMessage, then it will probably not only save the object contained in the message, but also the headers (containing the JMS properties). I don't think that you will be able to read the object back from the file simply using ObjectInputStream. Why don't you put that message on a test queue and read it from there?