Hello,
while trying some stuff with JMSReplyTo i figured out a strange behavior. I use a message driven bean which tries to bind the JMSReplyTo destination into JNDI.
public void onMessage(Message incomingMessage) {
try {
InitialContext ic = new InitialContext();
String jndiName = "macd/research/ReplyDestination";
Destination replyDestination = incomingMessage.getJMSReplyTo();
if (replyDestination instanceof Serializable) {
System.out.println("Destination is serializable!");
} else {
System.out.println("Destination is NOT serializable!");
}
ic.bind(jndiName + "Test", replyDestination);
} catch (JMSException e) {
// ignore for testing;
} catch (NamingException e) {
// ignore for testing;
}
}
The instanceof operation returns true. But if i try to bind the destination into JNDI i get the following error:
java.io.NotSerializableException: com.sun.messaging.jmq.jmsservice.Destination
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject(NamingUtils.java:64)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.bind(LocalSerialContextProviderImpl.java:89)
at com.sun.enterprise.naming.SerialContext.bind(SerialContext.java:461)
at javax.naming.InitialContext.bind(InitialContext.java:400)
at com.macd.research.temporaryqueues.MessageRegistrar.onMessage(MessageRegistrar.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1111)
at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:74)
at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:179)
at $Proxy58.onMessage(Unknown Source)
at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:258)
at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:76)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
This happens if the JMS service type is set to "embedded". If i switch it to "local" the above example works fine. Can anybody explain the difference between this types and why the example only works for the local type?
Regards,
Christian
[Message sent by forum member 'cplaetzinger' (cplaetzinger)]
http://forums.java.net/jive/thread.jspa?messageID=282683