Hi, I have an EJB that creates a TemporaryQueue, and attemps to pass this back to the client to use. Unfortunately this fails because the glassfish implementation of this appears to not be Serializable :-( Is there any way I can get round this problem?
Admin created Queues are serializable, but I need queues to be created on demand so aren't appropriate to use unless there's a way to plug into the glassfish server and have my EJB create a Queue?
[b]Glassfish version:[/b] Sun Java System Application Server 9.1_02 (build b04-fcs)
Here's my code:
[b][u]Application client[/u][/b]
[code]
package queue;
import javax.ejb.EJB;
import server.ExampleRemote;
public class Main
{
@EJB
private static ExampleRemote exampleBean;
public static void main(String[] args)
{
exampleBean.initJMS();
// This works
exampleBean.getQueue();
// This throws an exception
exampleBean.getTemporaryQueue();
}
}
[/code]
[b][u]Interface[/u][/b]
[code]
package server;
import javax.ejb.Remote;
import javax.jms.Queue;
import javax.jms.TemporaryQueue;
@Remote
public interface ExampleRemote {
public void initJMS();
public Queue getQueue();
public TemporaryQueue getTemporaryQueue();
}
[/code]
[b][u]Server EJB[/u][/b]
[code]
package server;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.Stateful;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TemporaryQueue;
@Stateful
public class ExampleBean implements ExampleRemote
{
@Resource(mappedName="jms/QueueConnectionFactory")
private ConnectionFactory connectionFactory;
@Resource(mappedName="jms/AdminCreatedQueue")
private Queue queue;
private Connection connection;
private Session session;
private TemporaryQueue temporaryQueue;
public void initJMS()
{
try
{
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
temporaryQueue = session.createTemporaryQueue();
} catch (JMSException ex)
{
Logger.getLogger(ExampleBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Queue getQueue()
{
return queue;
}
public TemporaryQueue getTemporaryQueue()
{
return temporaryQueue;
}
}
[/code]
This is the error message I get in the glassfish server log which relates to the call to getTemporaryQueue():
[code]
"IOP00100006: (BAD_PARAM) Class com.sun.messaging.jms.ra.DirectConnection is not Serializable"
org.omg.CORBA.BAD_PARAM: vmcid: OMG minor code: 6 completed: Maybe
at com.sun.corba.ee.impl.logging.OMGSystemException.notSerializable(OMGSystemException.java:990)
at com.sun.corba.ee.impl.logging.OMGSystemException.notSerializable(OMGSystemException.java:1005)
at com.sun.corba.ee.impl.util.Utility.throwNotSerializableForCorba(Utility.java:980)
at com.sun.corba.ee.impl.io.IIOPOutputStream.writeObjectField(IIOPOutputStream.java:762)
at com.sun.corba.ee.impl.io.IIOPOutputStream.outputClassFields(IIOPOutputStream.java:818)
at com.sun.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(IIOPOutputStream.java:232)
at com.sun.corba.ee.impl.io.IIOPOutputStream.outputObject(IIOPOutputStream.java:601)
at com.sun.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(IIOPOutputStream.java:187)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(ValueHandlerImpl.java:259)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(ValueHandlerImpl.java:241)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.writeValue(ValueHandlerImpl.java:179)
at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(CDROutputStream_1_0.java:839)
at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:935)
at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:949)
at com.sun.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(CDROutputStream_1_0.java:690)
at com.sun.corba.ee.impl.encoding.CDROutputStream.write_value(CDROutputStream.java:451)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.write(DynamicMethodMarshallerImpl.java:376)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.writeResult(DynamicMethodMarshallerImpl.java:472)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:158)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
[/code]
[Message sent by forum member 'antilochus' (antilochus)]
http://forums.java.net/jive/thread.jspa?messageID=322284