Hi guys! This question is more related to @pspeed.
So, I updated my project to jME 3.1, and decided to work in the multiplayer now. I created a simple login server, but I’m getting errors with the Serializer. I already looked at this post, and, in short, it says I don’t need to register the classes in the client. I tried that, but I get the error when I send messages:
java.lang.IllegalArgumentException: Class has not been registered:class messages.login.NewAccountMessage
at com.jme3.network.serializing.Serializer.getSerializerRegistration(Serializer.java:358)
at com.jme3.network.serializing.Serializer.getSerializerRegistration(Serializer.java:327)
at com.jme3.network.serializing.Serializer.writeClass(Serializer.java:402)
at com.jme3.network.serializing.Serializer.writeClassAndObject(Serializer.java:422)
at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol.java:73)
at com.jme3.network.base.DefaultClient.send(DefaultClient.java:266)
at com.jme3.network.base.DefaultClient.send(DefaultClient.java:226)
at main.Main.simpleInitApp(Main.java:109)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:227)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:131)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:212)
at java.lang.Thread.run(Thread.java:745)
In the server, I don’t get any problems IF I register the classes before turning on the server. I do the same thing to the Client.
The Client only works if I register the classes. I send two messages, a CreateNewAccount and LoginAttempt message. These two classes are registered in the Serializer.
When I send these messages, whether the server has or not registered them, I get errors in both ends:
Client:
Feb 23, 2016 12:44:43 PM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-19 = com.jme3.math.Vector3f, serializer=com.jme3.network.serializing.serializers.Vector3Serializer]
Feb 23, 2016 12:44:43 PM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-41 = com.jme3.network.serializing.serializers.FieldSerializer, serializer=null]
Feb 23, 2016 12:44:43 PM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-43 = [I, serializer=com.jme3.network.serializing.serializers.ArraySerializer]
Feb 23, 2016 12:44:43 PM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-46 = [Lcom.jme3.network.message.SerializerRegistrationsMessage$Registration;, serializer=com.jme3.network.serializing.serializers.ArraySerializer]
Feb 23, 2016 12:44:43 PM com.jme3.network.base.DefaultClient handleError
SEVERE: Termining connection due to unhandled error
com.jme3.network.kernel.ConnectorException: Connector closed.
at com.jme3.network.base.ConnectorAdapter.run(ConnectorAdapter.java:161)
Server:
Feb 23, 2016 12:44:43 PM com.jme3.network.base.KernelAdapter reportError
SEVERE: Unhandled error, endpoint:NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/127.0.0.1:1000 remote=/127.0.0.1:49653]], context:Envelope[NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/127.0.0.1:1000 remote=/127.0.0.1:49653]], reliable, 106]
java.lang.RuntimeException: Error deserializing object, clas ID:-48
at com.jme3.network.base.MessageProtocol.createMessage(MessageProtocol.java:184)
at com.jme3.network.base.MessageProtocol.addBuffer(MessageProtocol.java:160)
at com.jme3.network.base.KernelAdapter.createAndDispatch(KernelAdapter.java:216)
at com.jme3.network.base.KernelAdapter.run(KernelAdapter.java:280)
Caused by: com.jme3.network.serializing.SerializerException: Class not found for buffer data.
at com.jme3.network.serializing.Serializer.readClassAndObject(Serializer.java:390)
at com.jme3.network.base.MessageProtocol.createMessage(MessageProtocol.java:180)
... 3 more
So, I need youtr help guys. I’m running only one instance of Server and Client, if that helps.
Thanks,
Ev1lbl0w