This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes sending org.jdom.Document object  over JMS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "sending org.jdom.Document object  over JMS" Watch "sending org.jdom.Document object  over JMS" New topic
Author

sending org.jdom.Document object over JMS

nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
Hi,
I am getting following error while trying to receive a ObjectMessage.

Exception in thread "main" weblogic.jms.common.JMSException: Error deserializing
object
at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.jav
a:140)
at JMSReceiver.main(JMSReceiver.java:65)
----------- Linked Exception -----------
java.io.InvalidClassException: org.jdom.Document; local class incompatible: stre
am classdesc serialVersionUID = 607431889463202798, local class serialVersionUID
= -3468405884372921646
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.jav
a:128)
at JMSReceiver.main(JMSReceiver.java:65)
----------- Linked Exception -----------
java.io.InvalidClassException: org.jdom.Document; local class incompatible: stre
am classdesc serialVersionUID = 607431889463202798, local class serialVersionUID
= -3468405884372921646
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at weblogic.jms.common.ObjectMessageImpl.getObject(ObjectMessageImpl.jav
a:128)
at JMSReceiver.main(JMSReceiver.java:65)



This is the code where I am sending Document object


// locating connection factory
QueueConnectionFactory connectionFactory = (QueueConnectionFactory)context.lookup("ALConnectionFactory");
//locating queue
Queue queue= (Queue) context.lookup("Queue");

// create the connection
QueueConnection connection = connectionFactory.createQueueConnection();
// establishing the session
QueueSession session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
// creating sender
QueueSender sender = session.createSender(queue);
// create the message
//TextMessage msg = session.createTextMessage("this is sample queue from the JPO");
ObjectMessage msg = session.createObjectMessage((Serializable)doc);
// sends the message
sender.send(msg,DeliveryMode.NON_PERSISTENT, 4, 0);
//System.out.println(connectionFactory);
//System.out.println(queue);
connection.close();
session.close();

And this the code where I am trying to receive the Document object

QueueConnectionFactory connectionFactory = (QueueConnectionFactory)context.lookup("ALConnectionFactory");
//locating queue
Queue queue= (Queue) context.lookup("Queue");

// create the connection
QueueConnection connection = connectionFactory.createQueueConnection();
// establishing the session
QueueSession session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
// creating receiver
QueueReceiver receiver = session.createReceiver(queue);
// start the connection this is different b/n sender and receiver
connection.start();
//TextMessage msg = (TextMessage)receiver.receive();

// start
ObjectMessage msg = (ObjectMessage)receiver.receive();
Document doc = (Document) msg.getObject();


Please help me resolving this problem

Thanks
Nuthan
H Gokulam
Ranch Hand

Joined: Nov 04, 2003
Posts: 46
Hi Nuthan,

Only Serializable objects can be used in method 'createObjectMessage'. Just by typecasting a non-serializable object, you will not achieve this. The following statement just avoids the compilation error. But if 'doc' is not serializable, you will get runtime error.

ObjectMessage msg = session.createObjectMessage((Serializable)doc);

Regards,


Harikumar G<br />SCJP 1.4
nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
Hi Hari,
Thanks for your reply .. but doc object is of type org.jdom.Document which implements Serializable.I think that may not be the reason for this error, because the same code is just working fine in my personal system with same JDK version.

Thanks
Nuthan
H Gokulam
Ranch Hand

Joined: Nov 04, 2003
Posts: 46
Hi Nuthan,

Sorry for sending a reply without reading your question properly. You are right, org.jdom.Document implements Serializable. So, that is not the reason.

Reason for the error could be different versions of org.jdom.Document in the Client and Server. Try to use the same jar file (which contains org.jdom.Document) for server and for client.

Regards
nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
Hi Hari,
I tried with same jar file in client and server.. and still getting same error.

Nuthan
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You could add this to the server class.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
Still it is not working after adding the following statement also

static final long serialVersionUID = -3468405884372921646L;
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Try using the same JVM version for running both the client and server code. If you are using JRockit, then your client must be an Intel box.
nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
Hi,
I tried with same JVM and still facing same problem .. and it is working fine if I use org.dom4j.dom.DOMDocument instead of org.jdom.Document.

Is there any problem with jdom Document object ..?

Thanks
Nuthan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending org.jdom.Document object over JMS
 
Similar Threads
Exception while connecting the the Weblogic Server
JMS : USING JMS ReplyTo Queue
Getting very strange exception: JMS in EJB3, JBoss
JMS queue problem
JMS : Using JMS ReplyTo queue