Author |
Message
|
ckb |
Posted: Fri Sep 21, 2007 3:53 am Post subject: ClassNotFoundException while MQMessage.readObject() |
|
|
 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 |
|
 |
jefflowrey |
Posted: Fri Sep 21, 2007 5:49 am Post subject: |
|
|
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 |
|
 |
James_O_K |
Posted: Fri Sep 21, 2007 5:57 am Post subject: |
|
|
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 |
|
 |
ckb |
Posted: Fri Sep 21, 2007 6:08 am Post subject: |
|
|
 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 |
|
 |
jefflowrey |
Posted: Fri Sep 21, 2007 6:27 am Post subject: |
|
|
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 |
|
 |
|