Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Kryonet Registering Classes  (Read 320 times)
0 Members and 1 Guest are viewing this topic.
Offline Iversonblc

Senior Newbie


Exp: 3 years



« Posted 2014-03-03 15:22:33 »

I'm pretty deep into my project at this point, yet I've come across an issue with registering a class.

1  
2  
Mon Mar 03 10:22:00 EST 2014 ERROR:java.lang.IllegalArgumentException: Class is not registered: org.newdawn.slick.Animation$Frame
Note: To register this class use: kryo.register(org.newdawn.slick.Animation$Frame.class);


When I attempt to register: Serializer.register(org.newdawn.slick.Animation$Frame.class);  I have the following syntax error: cannot be referenced using its binary name.

I realize there is something wrong with the '$' character and Frame, yet I don't know what to do. I've tried registering just register(org.newdawn.slick.Animation.class); yet the issue still remains.

Additional Information:
The new Packet I've created contains a SpriteSheet and Animation variable.

Any thoughts on this?!
Thanks.
Offline trollwarrior1
« Reply #1 - Posted 2014-03-03 15:25:33 »

Hmmm.
From what I think I remember, $ means that the class file has been created from another class file. What I mean is that you probably cannot register classes that are within other classes. You need to specify a class that has it's own file and is not within other class.
Offline Iversonblc

Senior Newbie


Exp: 3 years



« Reply #2 - Posted 2014-03-03 15:45:29 »

Hmmm.
From what I think I remember, $ means that the class file has been created from another class file. What I mean is that you probably cannot register classes that are within other classes. You need to specify a class that has it's own file and is not within other class.

That is interesting and I'll obviously be investigating this further.. If anyone has any insights, please feel open to share   Cool
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline trollwarrior1
« Reply #3 - Posted 2014-03-03 15:48:08 »

Here is a short example.

Animation.java
1  
2  
3  
4  
5  
6  
public class Animation {
     
      public static class Frame {
         
      }
   }


I'm guessing this is how you got it setup.

Just take Frame and put it into it's own .java file.

Animation.java
1  
2  
3  
public class Animation {
     
   }


Frame.java
1  
2  
3  
public class Frame {
     
   }
Offline theagentd
« Reply #4 - Posted 2014-03-03 16:03:51 »

$ indicates an internal class nested in another one. You probably only register Animation, but you need to register both Animation and Animation.Frame.

Myomyomyo.
Offline Iversonblc

Senior Newbie


Exp: 3 years



« Reply #5 - Posted 2014-03-03 16:15:47 »

That is how I have my Packet infrastructure set up, not really the bug though.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public class Packet {

        public static class Packet1 {

            // ...

        }

        public static class Packet2 {

            // ...

        }
}



and I register via

1  
2  
3  
Kryo Serializer = client.getKryo();
Serializer.register(Packet.Packet1.class);
Serializer.register(Packet.Packet2.class);


My issue comes about from code inside one of my packets. I have an object, Player, which has always been able to exist as a local variable of Packet1 (lets say)

1  
2  
3  
4  
5  
6  
7  
8  
9  
public class Packet {

        public static class Packet1 {

            Player p = new Player();
           
            // not shown: get & set function for object p

        }


Recently I have added another object, which exists in Player
1  
2  
3  
4  
5  
6  
public class Player() {

        Spell s = new Spell();

            // not shown: get & set function for object s and initialization steps
}


Inside Spell:
1  
2  
3  
4  
5  
6  
7  
8  
public class Spell implements DrawableObject {

        public Animation animation = null;  //  object from: org.newdawn.slick.Animation
        public SpriteSheet sprite_sheet = null;  // object from: org.newdawn.slick.SpriteSheet

            // not shown: get & set function for objects and initialization steps

}



Here is the full trace:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
Exception in thread "Client" com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 7709
Serialization trace:
animation (spells.Spell)
MySpells (client_framework.Player)
p1 (client_framework.Team)
Team1 (client_framework.GameLobby)
G (client_framework.Packet$Packet2PlayerInit)
   at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:623)
   at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:747)
   at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.read(DefaultArraySerializers.java:340)
   at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.read(DefaultArraySerializers.java:293)
   at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:671)
   at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:224)
   at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:760)
   at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.read(DefaultArraySerializers.java:340)
   at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.read(DefaultArraySerializers.java:293)
   at com.esotericsoftware.kryo.Kryo.readObjectOrNull(Kryo.java:732)
   at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:229)
   at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:671)
   at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:224)
   at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:671)
   at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:224)
   at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:671)
   at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:224)
   at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:760)
   at com.esotericsoftware.kryonet.KryoSerialization.read(KryoSerialization.java:57)
   at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:137)
   at com.esotericsoftware.kryonet.Client.update(Client.java:239)
   at com.esotericsoftware.kryonet.Client.run(Client.java:317)
   at java.lang.Thread.run(Unknown Source)


The compiler gets hung up at the variable 'animation' located in Spell.java due to it being incorrectly registered (or something along those lines).

I thought what agentd said, yet for whatever reason I don't know how to find the accurate path in registering Animation.Frame

This is not recognized:
1  
Serializer.register(org.newdawn.slick.Animation.Frame.class);  // illegal, does not exist?



Thank you for your time.
Offline Cero
« Reply #6 - Posted 2014-03-03 16:22:10 »

I'm not sure you can serialize Slick internal classes with kryo just like that. like for example every class used by kryo needs an empty constructor too right ? but if you just use the lib as a jar you cannot implement that anyway
also imo you shouldnt save more to file than necessary but thats another discussion...

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (39 views)
2014-10-17 03:59:02

Norakomi (30 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (58 views)
2014-10-14 00:35:47

TehJavaDev (48 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!