I'm trying to get a simple client/server classes to communicate in order for later use to implement into my game for MP. The problem is I'm getting this Unable to create serializer
exception when I do new Client()
, a problem that apparently could be cause by having the ASM library outdated from the Kryonet jar.
Well, I went and did exactly that: update the library. I still get the error. The I went on to try the solution suggested at https://groups.google.com/forum/#!topic/kryonet-users/D5ssaQyWeR4
And still it didn't work...
I'm at a loss for ideas, the are no more solutions online different from what I've tried and seriously wasting my time with this bug. Really need to get past this to enlarge it to my game. The following is the error:
Exception in thread "main" java.lang.IllegalArgumentException: Unable to create serializer "com.esotericsoftware.kryo.serializers.FieldSerializer" for class: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
at com.esotericsoftware.kryo.Kryo.newSerializer(Kryo.java:337)
at com.esotericsoftware.kryo.Kryo.newDefaultSerializer(Kryo.java:316)
at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:309)
at com.esotericsoftware.kryo.Kryo.register(Kryo.java:353)
at com.esotericsoftware.kryonet.KryoSerialization.<init>(KryoSerialization.java:33)
at com.esotericsoftware.kryonet.KryoSerialization.<init>(KryoSerialization.java:25)
at com.esotericsoftware.kryonet.Client.<init>(Client.java:75)
at com.esotericsoftware.kryonet.Client.<init>(Client.java:57)
at gamep2.net.client.GameClient.<init>(GameClient.java:30)
at gamep2.net.client.GameClient.main(GameClient.java:55)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.esotericsoftware.kryo.Kryo.newSerializer(Kryo.java:324)
... 9 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
at com.esotericsoftware.reflectasm.FieldAccess.insertConstructor(FieldAccess.java:144)
at com.esotericsoftware.reflectasm.FieldAccess.get(FieldAccess.java:109)
at com.esotericsoftware.kryo.serializers.FieldSerializer.rebuildCachedFields(FieldSerializer.java:104)
at com.esotericsoftware.kryo.serializers.FieldSerializer.<init>(FieldSerializer.java:50)
... 14 more
Now, this is the simple Client class:
public class GameClient extends Thread{
public Client client;
public GameClient() throws IOException{
this.client = new Client();
this.register();
NetworkListener netList = new NetworkListener();
netList.init(client);
client.addListener(netList);
client.start();
Log.info("[CLIENT] Attempting to connect...");
client.connect(5000, "192.168.1.13", 54556);
}
public void register(){
Kryo kryo = client.getKryo();
kryo.register(Packet0LoginRequest.class);
kryo.register(Packet1LoginAnswer.class);
kryo.register(Packet2Message.class);
}
}
And now the Server class:
public class Start {
private static Server server;
private int port = 54556;
public Start() throws IOException{
server = new Server();
registerPackets();
server.addListener(new NetworkListener());
server.bind(port);
server.start();
System.out.println("Port: " + port);
System.out.println("Starting server...");
}
private void registerPackets(){
Kryo kryo = server.getKryo();
kryo.register(Packet0LoginRequest.class);
kryo.register(Packet1LoginAnswer.class);
kryo.register(Packet2Message.class);
}
public static void main(String[] args){
try {
new Start();
Log.set(Log.LEVEL_DEBUG);
} catch (IOException e) {
e.printStackTrace();
}
}
}