Java Help [SOLVED]

Any help would be appreciated



I’m going through the spider Monkey tutorial







I get this when i try to add a message listener

myClient.addMessageListener(new ClientMessageListener(), StringMessage.class);



java.lang.IllegalArgumentException: Class has not been registered:class messages.StringMessage



what does this mean? I Put this StringMessage class in a library, and add the exact same listener to the server and that operation succeeds, but for some reason my client does not :frowning:

You need to register all message types with the Serializer… and you need the exact same list in the exact same order on both client and server which is why recommended practice is to do this in a static method that both client and server share.

1 Like
@pspeed said:
you need the exact same list in the exact same order


ooh that is interesting... thanks for the tip, i think you just saved me a lot of time debugging a quirky problem
@kbender88 said:
ooh that is interesting... thanks for the tip, i think you just saved me a lot of time debugging a quirky problem


And just to be clear that we are talking about the same things...

I'm talking about registering the classes with the Serializer (the class that handles message serialization) and not registering listeners with the server or client. You can register listeners in whatever order and combination you want.

To save space in network messages, Serializer assigns an ID to every class and uses that instead of the class when sending messages... which is why the registration has to happen the same on both the client and server... so that all of the classes get the same IDs.