Object misses data after being send over the network (using SpiderMonkey)

I got an object which got a return value from a function. The function can also give exceptions, so the object also got an error variable and a hasError() and a getError() method.



Anyway, when I give the object an error message, it won’t be send to the client.

Before I send it, I test getError() and it gives the error message, when I receive it at the client and try it then, it will give null.



I’m using an abstract class that the object class has to override.



The abstract class is:

[java]package shared._network._messages._other;



import com.jme3.network.AbstractMessage;

import com.jme3.network.serializing.Serializable;





@Serializable

public abstract class AbstractMessageForFunction extends AbstractMessage

{

private final String errorMessage;





public AbstractMessageForFunction()

{

this.errorMessage = null;

}

public AbstractMessageForFunction( String errorMessage )

{

this.errorMessage = errorMessage;

}





public boolean hasError()

{

return (errorMessage != null);

}



public String getError()

{

return errorMessage;

}



public abstract Object getReturnValue();

}

[/java]



The object’s class is: (this will be send over the network)

[java]package shared._network._messages._authentication;



import com.jme3.network.serializing.Serializable;

import shared._network._messages._other.AbstractMessageForFunction;





@Serializable

public class LoginResultMessage extends AbstractMessageForFunction

{

public LoginResultMessage(){}

public LoginResultMessage( String error )

{

super( error );

}



public Object getReturnValue()

{

return null;

}

}

[/java]



What am I doing wrong?

@patrickvane1993 said:
private final String errorMessage;


That won't work. "final" means the message can only be set during construction... the Serializer sets it after the object has been constructed and thus would throw an error for final fields... and therefore doesn't bother to try to set them.
@pspeed said:
That won't work. "final" means the message can only be set during construction... the Serializer sets it after the object has been constructed and thus would throw an error for final fields... and therefore doesn't bother to try to set them.


ooow..... Thanks, I would have never figured that out.