• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

sending org.jdom.Document object over JMS

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
nuthan kumar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hari,
I tried with same jar file in client and server.. and still getting same error.

Nuthan
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could add this to the server class.
 
nuthan kumar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still it is not working after adding the following statement also

static final long serialVersionUID = -3468405884372921646L;
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic