Error Sending a Message from simpleUpdate()

Hello,



I’m currently implementing some network capabilites to my game and do now encounter an error when sending messages in my game loop.

When sending messages as a response of a MessageListener receiving a message it’s working good, but when using this in a method called by simpleUpdate of my server I get one of those following erros and do not understand why or how to prevent them from occuring. Google did not help much…



Here are the errors:



[java]java.lang.RuntimeException: Error serializing message

at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol.java:82)

at com.jme3.network.base.DefaultServer$Connection.send(DefaultServer.java:489)

at logic.Logic.updateUser(Logic.java:126)

at server.ProjectServer.simpleUpdate(ProjectServer.java:108)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)

at com.jme3.system.NullContext.run(NullContext.java:131)

at java.lang.Thread.run(Unknown Source)

Caused by: com.jme3.network.serializing.SerializerException: Error writing object for field:private java.util.List server.messages.EntityUpdateMessage.updates

at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(FieldSerializer.java:182)

at com.jme3.network.serializing.Serializer.writeClassAndObject(Serializer.java:393)

at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol.java:74)

… 6 more

Caused by: com.jme3.network.serializing.SerializerException: Error writing object for field:private com.jme3.math.Vector3f server.updates.EntityUpdate.pos

at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(FieldSerializer.java:182)

at com.jme3.network.serializing.serializers.CollectionSerializer.writeObject(CollectionSerializer.java:105)

at com.jme3.network.serializing.Serializer.writeClassAndObject(Serializer.java:393)

at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(FieldSerializer.java:177)

… 8 more

Caused by: java.lang.NullPointerException

at com.jme3.network.serializing.serializers.Vector3Serializer.writeObject(Vector3Serializer.java:24)

at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(FieldSerializer.java:175)

… 11 more[/java]

[java]java.lang.RuntimeException: Error serializing message

at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol.java:82)

at com.jme3.network.base.DefaultServer$Connection.send(DefaultServer.java:489)

at logic.Logic.updateUser(Logic.java:128)

at server.ProjectServer.simpleUpdate(ProjectServer.java:108)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)

at com.jme3.system.NullContext.run(NullContext.java:131)

at java.lang.Thread.run(Unknown Source)

Caused by: com.jme3.network.serializing.SerializerException: Error writing object for field:private java.util.List server.messages.EntityUpdateMessage.updates

at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(FieldSerializer.java:182)

at com.jme3.network.serializing.Serializer.writeClassAndObject(Serializer.java:393)

at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol.java:74)

… 6 more

Caused by: java.lang.NullPointerException

at com.jme3.network.serializing.serializers.CollectionSerializer.writeObject(CollectionSerializer.java:89)

at com.jme3.network.serializing.Serializer.writeClassAndObject(Serializer.java:393)

at com.jme3.network.serializing.serializers.FieldSerializer.writeObject(FieldSerializer.java:177)

… 8 more[/java]

In both cases it looks like you have a field that is null for a type whose serializer doesn’t handle that very well. I try to fix them as a find them but it often changes the protocol and adds a byte to the messages that cannot easily handle it.



In these cases it is easier to make sure that you do not have null vector3f or null List fields. Though List might be one I can fix easily.

1 Like

Thank you very much : )

Didn’t notice this difference when searching for reasons for this different behaviour.

Now I can prevent null from being used I hope.

It’s not really a different behavior. You are just sending different messages in these cases and they have null fields where nulls of those particular types aren’t serializable.



SpiderMonkey is otherwise behaving consistently no matter where you call it.