Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.io.NotSerializableException

843830Aug 5 2004 — edited Aug 9 2004
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2004
Added on Aug 5 2004
2 comments
179 views