Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

NotSerializableException for transient field?

I have a class that contains a transient field in it. I am getting a NotSerializableException when GigaSpaces is trying to serialize the object that contains it - and the error is that the transient field is not Serializable. Any idea why this would happen?

Basically, the class looks like this:

@SpaceClass(persist=false) public class MyClass implements Serializable { private static final long serialVersionUID = 2549514413980948861L; transient private AnotherClass anotherObject; private int shipmentId = -1; }

I am getting this exception when writing an object of this type to GigaSpaces:

org.openspaces.core.WriteMultipleException: Success:0, errors:100, [class com.gigaspaces.lrmi.nio.MarshallingException:100 StackTrace: com.gigaspaces.lrmi.nio.MarshallingException: Failed to marsh: [RequestPacket: interface com.gigaspaces.internal.remoting.RemoteOperationsExecutor.executeOperationAsync(com.gigaspaces.internal.remoting.RemoteOperationRequest WriteEntriesSpaceOperationRequest[entriesPackets={EntryPacket[typeName=com.csx.nbc.gspaces.model.MyClass,uid=523147275^44^254072892^0^0,version=0,operationId=ID:3197289002568070186.2300],EntryPacket[typeName=com.csx.nbc.gspaces.model.MyClass,uid=523147275^44^254047676^0^0,version=0,operationId=ID:3197289002568070186.2301],etc. etc.

,txn=null,lease=9223372036854775807,leases=null,modifiers=4096]), isOneWay = false, isCallBack = false] at com.gigaspaces.lrmi.nio.Writer.writePacket(Writer.java:208) at com.gigaspaces.lrmi.nio.Writer.writeRequest(Writer.java:142) at com.gigaspaces.lrmi.nio.async.AsyncContext.handleWrite(AsyncContext.java:327) at com.gigaspaces.lrmi.nio.selector.handler.client.ClientHandler.handleConnection(ClientHandler.java:150) at com.gigaspaces.lrmi.nio.selector.handler.AbstractSelectorThread.doSelect(AbstractSelectorThread.java:75) at com.gigaspaces.lrmi.nio.selector.handler.AbstractSelectorThread.run(AbstractSelectorThread.java:51) at java.lang.Thread.run(Thread.java:779) Caused by: com.j_spaces.core.EntrySerializationException: Failed to serialize property #1 (Name=[anotherObject], Type=[com.csx.nbc.gspaces.dao.AnotherClass]) in entry of type [com.csx.nbc.gspaces.model.MyClass]. Value=[com.csx.nbc.gspaces.dao.AnotherClass@318ef9c0] at com.gigaspaces.internal.transport.EntryPacket.createPropertySerializationException(EntryPacket.java:436) at com.gigaspaces.internal.transport.EntryPacket.serializePacket(EntryPacket.java:332) at com.gigaspaces.internal.transport.EntryPacket.writeExternal(EntryPacket.java:300) at com.gigaspaces.internal.transport.AbstractEntryPacket.writeExternalImpl(AbstractEntryPacket.java:289) at com.gigaspaces.internal.serialization.AbstractExternalizable.writeExternal(AbstractExternalizable.java:32) at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1463) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1434) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1194) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:363) at com.gigaspaces.internal.serialization.ObjectClassSerializer.write(ObjectClassSerializer.java:36) at com.gigaspaces.internal.io.IOUtils.writeObject(IOUtils.java:656) at com.gigaspaces.internal.io.IOUtils.writeObjectArray(IOUtils.java:699) at com.gigaspaces.internal.client.spaceproxy.operations.WriteEntriesSpaceOperationRequest.writeExternal(WriteEntriesSpaceOperationRequest.java:279) at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1463) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1434) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1194) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:363) at com.gigaspaces.internal.io.IOUtils.marshalValue(IOUtils.java:246) at com.gigaspaces.lrmi.nio.RequestPacket.writeExternal(RequestPacket.java:250) at com.gigaspaces.lrmi.nio.Writer.writePacket(Writer.java:203) ... 6 more Caused by: java.io.NotSerializableException: com.csx.nbc.gspaces.dao.AnotherClass at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1200) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:363) at com.gigaspaces.internal.serialization.ObjectClassSerializer.write(ObjectClassSerializer.java:36) at com.gigaspaces.internal.io.IOUtils.writeObject(IOUtils.java:656) at com.gigaspaces.internal.io.IOUtils.writeObjectArray(IOUtils.java:699) at com.gigaspaces.internal.io.IOUtils.writeObjectArrayCompressed(IOUtils.java:804) at com.gigaspaces.internal.transport.EntryPacket.serializePacket(EntryPacket.java:328) ... 24 more

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=4081]{quote}

asked 2013-05-22 14:00:33 -0600

rickfish gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

On the getter method of the anotherObject have @SpaceExclude - see example below:

@SpaceClass
public class Person
{
    private String lastName;
    private String firstName;
    transient private AnotherClass anotherObject;
...

public String getFirstName() {return firstName;}
public void setFirstName(String firstName) {this.firstName = firstName;}

public String getAge() {return age;}
public void setAge(String age) {this.age = age;}

@SpaceExclude
    AnotherClass getAnotherObject()
    {
         return anotherObject;
}

void setAnotherObject(AnotherClass anotherObject)
    {
    this.anotherObject=anotherObject;
    }
}

See more:
http://wiki.gigaspaces.com/wiki/display/XAP95/POJOMetadata#POJOMetadata-FieldLevelDecoration@SpaceExclude

Shay

answered 2013-05-22 14:34:04 -0600

shay hassidim gravatar image
edit flag offensive delete link more
0

Ok...thanks Shay!

answered 2013-05-22 15:06:30 -0600

rickfish gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-05-22 14:00:33 -0600

Seen: 561 times

Last updated: May 22 '13