I implemented an own Marshalling/Unmarshalling Sytem with JMS (exercise). I do Request and get Responses back. I want to fire an own callback in response after i received the correct response. But i think my exception is a serialization problem. But i don’t know how to fix it.
I use that code to call a server
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Request request = new Request("printServer:" + printMessage.getText());
request.setAsyncCallback(new AsyncCallback() {
/**
*
*/
private static final long serialVersionUID = 5204649755139243369L;
@Override
public void onSuccess(String content) {
System.out.println("async callback: " + content);
}
});
c.callServer(request);
}
});
My request looks like this:
public class Request extends Conveyable
{
private static final long serialVersionUID = 4535036450648916878L;
public static int requestIDInc = 0;
private int requestID;
private AsyncCallback callback;
public Request(String content)
{
super(content);
synchronized (this) {
requestID = ++requestIDInc;
}
}
public int getRequestID() {
return requestID;
}
public AsyncCallback getAsyncCallback() {
// TODO Auto-generated method stub
return callback;
}
public void setAsyncCallback(AsyncCallback callback)
{
this.callback = callback;
}
}
My own Callback looks like this:
public abstract class AsyncCallback implements Serializable{
/**
*
*/
private static final long serialVersionUID = 4951246599084406476L;
public abstract void onSuccess(String content);
}
And the exception i got is this:
javax.jms.MessageFormatException: machines.client.ClientWindow$1
at org.exolab.jms.message.ObjectMessageImpl.setObject(ObjectMessageImpl.java:194)
It looks a little bit as if the ClientWindow in which a create the Request and fire it off with a buttonClick is included in this callback. But i don’t know why. Or maybe the problem isn’t there.
Your subclass of AsyncCallback is created as an inner class inside ClientWindow. Non-static inner classes contain a reference back to the parent class.