ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » ClassNotFoundException while MQMessage.readObject()

Post new topic  Reply to topic
 ClassNotFoundException while MQMessage.readObject() « View previous topic :: View next topic » 
Author Message
ckb
PostPosted: Fri Sep 21, 2007 3:53 am    Post subject: ClassNotFoundException while MQMessage.readObject() Reply with quote

Newbie

Joined: 21 Sep 2007
Posts: 2

Hi,
I am adding a object to a message queue. But when I read the object back from the queue it is throwing a ClassNotFoundException.
I am using websphere 5.1.2.

The error is as follows

java.lang.ClassNotFoundException: MyClass
at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java(Compiled Code))
at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:588)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1543)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1465)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1656)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1304)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:354)
at com.ibm.mq.MQMessage.readObject(MQMessage.java:1100)

Anybody help me fix this.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Sep 21, 2007 5:49 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

This is a good example of why it's a poor idea to use ObjectMessages.

The class that describes the object has to be available in the classloader on both sides. And every class that the object uses.

You're going to be much better off if you use XML or some other text format to store your data on the queue. If nothing else, you can look at using JMS Map or Stream messages.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
James_O_K
PostPosted: Fri Sep 21, 2007 5:57 am    Post subject: Reply with quote

Apprentice

Joined: 09 Mar 2006
Posts: 39
Location: UK

This is a pretty basic error! Have you deployed your code to Websphere correctly? The websphere classpath needs to know about your "MyClass" you created. Try as a start adding the jar file with your MyClass in it on to the Websphere classpath.
Back to top
View user's profile Send private message
ckb
PostPosted: Fri Sep 21, 2007 6:08 am    Post subject: Reply with quote

Newbie

Joined: 21 Sep 2007
Posts: 2

jefflowrey wrote:
This is a good example of why it's a poor idea to use ObjectMessages.

The class that describes the object has to be available in the classloader on both sides. And every class that the object uses.

You're going to be much better off if you use XML or some other text format to store your data on the queue. If nothing else, you can look at using JMS Map or Stream messages.


I have the same class on both sides. Is there any solution using objects alone?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Sep 21, 2007 6:27 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you have the same class available on both sides, then you wouldn't be getting the error that you're getting.

Either that, or there's a problem in the particular version and fix level of WMQ that you're using.

Or something is somehow mangling the messages between the sender and the receiver.

It should be possible to do this with only ObjectMessages. But only Java programs will ever be able to read the messages, and only Java programs that have all required classes on the classpath.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » ClassNotFoundException while MQMessage.readObject()
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.