Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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] 'Field not declared as byte: 0'  (Read 1098 times)
0 Members and 1 Guest are viewing this topic.
Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Posted 2013-05-21 10:49:15 »

I'm getting an Exception I've not got before, after I added another type of Message (simply a class for me):
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: Field not declared as byte: 0
   at org.matheusdev.ror.net.packages.CreateEntityFieldAccess.getByte(Unknown Source)
   at com.esotericsoftware.kryo.serializers.FieldSerializer$ByteField.write(FieldSerializer.java:403)
   at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:213)
   at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:571)
   at com.esotericsoftware.kryonet.KryoSerialization.write(KryoSerialization.java:50)
   at com.esotericsoftware.kryonet.TcpConnection.send(TcpConnection.java:192)
   at com.esotericsoftware.kryonet.Connection.sendTCP(Connection.java:59)
   ...


But what does that mean?

In my game all Messages extend one class
NetPackage
. I've changed it to include some info like that:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public abstract class NetPackage {

+   public static final byte TCP = 1;
+   public static final byte UDP = 2;

    public long time = 0;
+   public byte type = 0;

    public NetPackage() {
    }

    public NetPackage(long time, byte type) {
        this.time = time;
+       this.type = type;
    }
}


Now I get that exception (which says nothing useful to me, btw), and I don't know why. I simply sent a subclass of NetPackage (both classes are registered, I checked it) over TCP to the Localhost on a port which worked all the time before...

What's wrong?

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Nate

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2013-05-21 13:38:40 »

Probably you have mismatched classes on either end of the network.

Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #2 - Posted 2013-05-21 13:56:22 »

No, impossible, I use the same codebase for both client and server...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #3 - Posted 2013-05-22 04:34:22 »

Not sure then, you'll have to debug it, debug/trace logging, simpler testcase using only Kryo, etc.

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2013-05-22 08:10:36 »

You said you made a change, I assume undoing that change fixes it? Because its entirely possible something else is the problem. I've had that happen to me in the past that I was looking in the wrong place.
Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #5 - Posted 2013-05-22 08:54:11 »

-.-

Seriously?
Kryo doesn't like the variable name "type"... I've chnaged it to "connectionType" and it worked...
 Cranky

Seems like there has to be done something, Nate  Pointing
(To me, at least, it seems like a bug...)

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Nate

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #6 - Posted 2013-05-22 11:53:31 »

There should be no problem "type" or any other field name. o.O Probably you classes were out of date, as I said. Smiley

Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #7 - Posted 2013-05-22 12:03:01 »

There should be no problem "type" or any other field name. o.O Probably you classes were out of date, as I said. Smiley

Impossible, no, they were not.
I've changed the code several times, everytime I changed something to test, whether the change makes it work, I restarted both server and client (which were both compiled with the newest code, of course).
Between two times running I simply changed the name of the variable from "type" to "connectiontype" and it worked.

It's impossible I could have had two different class versions between my server and client.  Stare

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
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.

UprightPath (20 views)
2014-09-20 20:14:06

BurntPizza (26 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (95 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29

BurntPizza (52 views)
2014-09-07 01:13:42

Longarmx (39 views)
2014-09-07 01:12:14

Longarmx (45 views)
2014-09-07 01:11:22
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!