Page 1 of 1

how to reload java class but don't restart sfs ?

Posted: 15 Jan 2013, 06:33
by huhailong
i create a class MyOSExtension extends OpenSpaceExtension, this class will create all room and other data when sfs2x start. only this one class extends AbstractExtension in my whole project.
i put this class to fox2Extension.jar, this jar also has some other class to handle the client request,
right now i changed some other class and export to fox2Extension.jar,
class MyOSExtension didn't change, but when jar replaced, the class MyOSExtension automaticlly running (i setted reload mode = auto), so it will create all room again but failed.
if sfs don't restart, it will occur issue for our sfs game.
the issue log is :
11:35:03,168 INFO [com.smartfoxserver.v2.controllers.ExtensionController-3] utils.Logger - [OpenSpace] User dragon [0] requested path from (52, 56, 0) to (56, 58, 0) on map 'floors/b801_fn1#A'
11:35:03,172 ERROR [com.smartfoxserver.v2.controllers.ExtensionController-3] utils.Logger - [OpenSpace] java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: An unexpected exception occurred while the OpenSpace Core Extension executed command path
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.openspace.commands.CalculatePathCommand.execute(CalculatePathCommand.java:84)
com.smartfoxserver.openspace.handlers.OSRequestHandler.handleClientRequest(OSRequestHandler.java:81)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:192)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:133)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Re: how to reload java class but don't restart sfs ?

Posted: 15 Jan 2013, 09:57
by Bax
If you deploy the OpenSpace Extension without restarting the server, all its inner data is lost of course - for example all maps and the related pathfinding data. If a user is on that map and after the Extension is reloaded he clicks on a tile to make the avatar move, the Extension won't find the pathfinding data structures anymore, throwing that error.

You have to restart the server when you deploy your OpenSpace Extension, or at least make all users leave the Rooms corresponding to virtual environments before hot-deploying the Extension. In this case in fact when the first user enters a Room again, the corresponding map data is reloaded and everything should work as expected.

Re: how to reload java class but don't restart sfs ?

Posted: 16 Jan 2013, 02:51
by huhailong
i upgraded my project from sfs1.6.6 to sfs2.5.0,
for sfs1.6.6, one zone can has a few Extension class, for example: 1, class MainExtension extends AbstractExtension; 2,class MyOS extends OpenSpaceExtension
but for sfs2.5.0, one zone only can set one SFSExtension class, so i must create a class MyOSExtension extends OpenSpaceExtension if i want to use OpenSpace,
i didn't change MyOSExtension, only changed other handle client request class, but MyOSExtension class also auto runned,
so the result is that i can not auto reload java class if i want to use OpenSpace, is correct ?

Re: how to reload java class but don't restart sfs ?

Posted: 16 Jan 2013, 09:44
by Bax
In SFS2X all classes used by your Extension are contained in the same jar file. Even if you modify another class, when you deploy the new jar all the classes it contains are reloaded, including the Extension one.
The auto-reaload works only if no users are inside rooms corresponding to OpenSpace maps. Otherwise yes, you have to restart the server.