java.io.NotSerializableException
843830Aug 5 2004 — edited Aug 9 2004Hi,
I am trying to use JMS... I want to use a MessageProducer in order to send messages. Here is a part of my code:
public class InfoVehi implements java.io.Serializable
{
private String id, lat, lon, hora;
[...]
public InfoVehi(String idr, String latr, String lonr, String horar)
{
id=idr;
lat=latr;
lon=lonr;
hora=horar;
}
public void CrearTopic(){ //creates connection, session, topic, message producer...
[...]
}
public void Enviar() //sends a message (I would like...)
{
try{
msgProd.send(sess.createObjectMessage(this));
}catch(Exception exc)
{
exc.printStackTrace();
}
}
public static void main(String[] args)
{
InfoVehi env=new InfoVehi("hy","gt","fr","de"); // I create my object
try{
env.CrearTopic();
System.out.println("MsgProd creado");
env.Enviar(); // I send it
}catch(Exception exc)
{
exc.printStackTrace();
}
}
But it throws this exception:
com.sun.messaging.jms.MessageFormatException: [C4014]: Serialize message failed.
- cause: java.io.NotSerializableException: com.sun.messaging.jms.ra.ConnectionA
dapter
at com.sun.messaging.jmq.jmsclient.ObjectMessageImpl.setObject(ObjectMes
sageImpl.java:144)
at com.sun.messaging.jmq.jmsclient.SessionImpl.createObjectMessage(Sessi
onImpl.java:1405)
at com.sun.messaging.jms.ra.SessionAdapter.createObjectMessage(SessionAd
apter.java:172)
at mypackage1.InfoVehi.Enviar(Unknown Source)
at mypackage1.InfoVehi.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
...
However, my class "InfoVehi" implements "java.io.Serializable"... I don't understand!!!
If somebody can help me...
Gracias,
Charlouze