I'm confused with class-serialization. help me...

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

wakawa2003
Posts: 14
Joined: 03 May 2019, 15:04

I'm confused with class-serialization. help me...

Postby wakawa2003 » 03 May 2019, 15:37

I get error message: "20:14:09,078 WARN [SFSWorker:Sys:2] protocol.SFSProtocolCodec - Error deserializing request: com.smartfoxserver.v2.exceptions.SFSRuntimeException: java.lang.ClassNotFoundException: RPCInfor"

I guess that error appen because i don't understand exactly what is "RpgModel.jar" in this link http://docs2x.smartfoxserver.com/AdvancedTopics/class-serialization

That is Jar build file of Class i want to send? or something else?

Code: Select all

» Deploying the Extension
...
In order to avoid this problem we need to make sure that the model classes are deployed in the extensions/__lib__/ folder. So for this example we have prepared two files, RpgModel.jar which goes in extensions/__lib__/ and RpgExtension.jar which goes in extensions/rpg/.


Thank you!
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: I'm confused with class-serialization. help me...

Postby Lapo » 06 May 2019, 08:14

Hi,
essentially you need the same classes on both sides of the communication.

If you have a classe Spaceship under the namespace my.game from client side you will need an equivalent class with the same name and package name on the server side.

In this case it looks like the server side is not able to find the class that maps to the object sent from the client side.

The RpgModel.jar from the example is the jar file containing all classes that map the objects you're sending from client side.
When the server receives a serialized version of the SpaceShip class from the client it will look for the same class in the global classpath. If the class can't be found it will throw an Exception such as the one you've reported.

Since Extensions are loaded in the their custom class loader, the server will not be able to find those classes. Hence the need to deploy them separately at the top level of the classpath.

If you're not entirely familiar with the classloading mechanism in Java you should read this:
http://docs2x.smartfoxserver.com/Extens ... d-concepts

If you prefer to avoid class loading issues altogether simply deploy all your Extension classes under extensions/_lib_/

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
wakawa2003
Posts: 14
Joined: 03 May 2019, 15:04

Re: I'm confused with class-serialization. help me...

Postby wakawa2003 » 07 May 2019, 07:38

Thank you!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 68 guests