Registration error: no-argument constructor not found

I am trying to create a server for my game but everytime I run it, it throws off this error (See title). It points here:
Serializer.registerClass(connected.class);

Here is connected.class:
@Serializable
public class connected extends AbstractMessage {
public connected() {} // empty constructor
}

Any ideas on how to fix it? I am running only the code from the wiki page for spidermonkey but this error always appears. Thanks for all your help!

Here is the full error:
SEVERE: Uncaught exception thrown in Thread[Headless Application Thread,5,main]
java.lang.RuntimeException: Registration error: no-argument constructor not found on:class Server.Server$connected
at com.jme3.network.serializing.serializers.FieldSerializer.checkClass(FieldSerializer.java:57)
at com.jme3.network.serializing.serializers.FieldSerializer.initialize(FieldSerializer.java:63)
at com.jme3.network.serializing.Serializer.registerClassForId(Serializer.java:179)
at com.jme3.network.serializing.Serializer.registerClass(Serializer.java:207)
at com.jme3.network.serializing.Serializer.registerClass(Serializer.java:148)
at Server.Server.simpleInitApp(Server.java:41)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.NullContext.initInThread(NullContext.java:84)
at com.jme3.system.NullContext.run(NullContext.java:127)
at java.lang.Thread.run(Thread.java:722)

“no-argument constructor not found on:class Server.Server$connected”

It’s because it’s not a static inner class. When you have a non-static inner class then there is a hidden parameter to the outer instance since you cannot instantiate a non-static inner class without having an instance of the outer class.

Make the class static or break it out into its own class. The latter is probably a safer idea since you will need this exact same class available on both client and server… registered in the EXACT same order.

1 Like

Sorry if this is an idiotic question but what do you mean by ‘‘breaking the class out’’?

Also, thanks so much for your answer! By setting the class as static, it works beautifully now! I still wonder what you meant with the latter solution though.

he meant,: put it in a own file as public class