Zone and Room class loader problem

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

Moderators: Lapo, Bax

grhwood
Posts: 116
Joined: 15 Mar 2011, 04:43

Zone and Room class loader problem

Postby grhwood » 24 Mar 2011, 08:06

I have ZoneExtension class and RoomExtension class inside the same ext.jar. The ZoneExtension class is config to a zone extension by using admin tool. The RoomExtension class is dynamically create at runtime using SFSApi#createRoom.

The problem is when i handle a event for example USER_JOIN_ROOM at zone level and use this :

RoomExtension roomExt = (RoomExtension )room.getExtension();

ClassCastException is throwed. When i trace it: RoomExtension.class.
getClassLoader() and room.getExtension().getClass().getClassLoader() are 2 difference class loaders.

Thank you.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 25 Mar 2011, 07:49

Your extension jar needs to sit in __lib__ so that the class loader can get the exact same class. This is not possible if the extension is loaded by multiple class loaders (one for the zone, one for the room)

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 121 guests