1

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.

Roger
  • 7,062
  • 13
  • 20
Sherin Syriac
  • 447
  • 6
  • 13
  • It seems that there are several possible causes of "invalid stream header." Yes, you need to verify that the classes you obtained have the same `serialVersionUID` as the classes that generated the contents of the Object message. – noahlz Sep 21 '12 at 14:38
  • Can you show us the code you use to serialize? – Plínio Pantaleão Sep 21 '12 at 14:38
  • I believe it is the same. But I just wanted to know how the objects are serialized when put to the Queue(Probably something internal to IBM websphere and I don't have any source code for that). – Sherin Syriac Sep 21 '12 at 14:50
  • @Plinio As I mentioned I don't have access to serialization code as this would be done when I send messages to MQ using the following code Context context = new InitialContext(); // lookup queue Queue queue = (Queue)PortableRemoteObject.narrow(context.lookup(jndiQueueName), Queue.class); // create sender sender = session.createSender(queue); // create text message ObjectMessage textMessage = session.createObjectMessage(message); // send text message to queue sender.send(textMessage); – Sherin Syriac Sep 21 '12 at 15:16
  • when the message is send that must be the place it is serialized. The sender class implementation is an IBM class named com.ibm.ejs.jms.JMSWrapQueueSender . (Sorry about the bad code format in the comments) – Sherin Syriac Sep 21 '12 at 15:17

1 Answers1

0

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?

Andreas Veithen
  • 8,868
  • 3
  • 25
  • 28
  • @ Andreas Veithen that is what I finally ended up doing. Reloaded the messages from production into my development environment and debugged it. Thank you all very much for your responses. – Sherin Syriac Sep 25 '12 at 15:31