2015-10-26 125 views
-1

我剛開始使用kryonet。java kryonet - ChatMessage - 類未註冊

從示例文件夾運行時,聊天示例正常工作。

如果我將聊天客戶端,服務器和網絡文件複製到eclipse中的另一個源文件夾中,我得到IllegalArgumentException:類未註冊:com.esotericsoftware.kryonet.examples.chat.Network $ RegisterName(請參見下文) 。

我在「kryo.register(ChatMessage.class);」中添加了打印輸出,所以我知道這是被調用的。

客戶端掛起嘗試連接。

任何指針將不勝感激。

感謝

00:05 INFO: [kryonet] Connecting: localhost/127.0.0.1:22222 
00:05 DEBUG: [kryonet] Port 59450/TCP connected to: localhost/127.0.0.1:22222 
00:05 DEBUG: [kryo] Read: RegisterTCP 
00:05 INFO: [kryonet] Connection 1 connected: localhost/127.0.0.1 
Exception in thread "Client" java.lang.IllegalArgumentException: Class is not registered: com.esotericsoftware.kryonet.examples.chat.Network$RegisterName 
Note: To register this class use: kryo.register(com.esotericsoftware.kryonet.examples.chat.Network$RegisterName.class); 
    at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:461) 
    at com.esotericsoftware.kryo.util.DefaultClassResolver.writeClass(DefaultClassResolver.java:79) 
    at com.esotericsoftware.kryo.Kryo.writeClass(Kryo.java:491) 
    at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:596) 
    at com.esotericsoftware.kryonet.KryoSerialization.write(KryoSerialization.java:66) 
    at com.esotericsoftware.kryonet.TcpConnection.send(TcpConnection.java:210) 
    at com.esotericsoftware.kryonet.Connection.sendTCP(Connection.java:87) 
    at com.tayek.kryo.ChatClient$1.connected(ChatClient.java:55) 
    at com.esotericsoftware.kryonet.Connection.notifyConnected(Connection.java:242) 
    at com.esotericsoftware.kryonet.Client.update(Client.java:284) 
    at com.esotericsoftware.kryonet.Client.run(Client.java:356) 
    at java.lang.Thread.run(Unknown Source) 

回答

0
Exception in thread "Client" java.lang.IllegalArgumentException: Class is not registered: com.esotericsoftware.kryonet.examples.chat.Network$RegisterName 
Note: To register this class use: kryo.register(com.esotericsoftware.kryonet.examples.chat.Network$RegisterName.class); 

堆棧跟蹤說Network$RegisterName類沒有註冊。

註冊此課程,您的項目將照常開始工作。