User: chirino
Date: 01/08/25 22:35:57
Modified: src/main/org/jboss/mq SpyObjectMessage.java
Log:
Fixed the a serialization problem. ClassNotFoundExceptions were being thrown
when a MDB would receive a ObjectMessage.
Revision Changes Path
1.5 +20 -2 jbossmq/src/main/org/jboss/mq/SpyObjectMessage.java
Index: SpyObjectMessage.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/SpyObjectMessage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SpyObjectMessage.java 2001/08/17 23:32:26 1.4
+++ SpyObjectMessage.java 2001/08/26 05:35:57 1.5
@@ -17,7 +17,7 @@
*
* @author Norbert Lataille ([EMAIL PROTECTED])
* @created August 16, 2001
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class SpyObjectMessage
extends SpyMessage
@@ -65,7 +65,25 @@
retVal = new byte[objectBytes.length];
System.arraycopy( objectBytes, 0, retVal, 0, objectBytes.length );
} else {
- ObjectInputStream input = new ObjectInputStream( new
ByteArrayInputStream( objectBytes ) );
+
+ /**
+ * Default implementation ObjectInputStream does not work
well
+ * when running an a micro kernal style app-server like
JBoss.
+ * We need to look for the Class in the context class loader
+ * and not in the System classloader.
+ *
+ * Would this be done better by using a MarshaedObject??
+ */
+ class ObjectInputStreamExt extends ObjectInputStream {
+ ObjectInputStreamExt(InputStream is) throws
IOException {
+ super(is);
+ }
+ protected Class resolveClass(ObjectStreamClass v)
throws IOException, ClassNotFoundException {
+ return
Thread.currentThread().getContextClassLoader().loadClass(v.getName());
+ }
+ }
+
+ ObjectInputStream input= new ObjectInputStreamExt(new
ByteArrayInputStream(objectBytes));
retVal = ( Serializable )input.readObject();
input.close();
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development