SFSExtensionException

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

Moderators: Lapo, Bax

igjchhabria
Posts: 4
Joined: 04 Jan 2013, 08:14

SFSExtensionException

Postby igjchhabria » 14 Jan 2013, 13:53

Hi guys,

I've been trying to load Room Extension Dynamically. As a part of the test, I was loading an Extension JAR for a Room through my code whilst No such JAR existed.
Accordingly, I got the Error in my Logs :
[com.smartfoxserver.v2.controllers.ExtensionController-1] man
agers.SFSRoomManager -
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSExtensionException
Message: Class not found: Main.ProofForJitesh
Description: Failure while creating room extension.
Possible Causes: If the CreateRoom request was sent from client make sure that t
he extension name matches the name of an existing extension
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createJavaExtension(
SFSExtensionManager.java:364)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSE
xtensionManager.java:266)
com.smartfoxserver.v2.entities.managers.SFSRoomManager.createRoomExtension(SFSRo
omManager.java:209)
com.smartfoxserver.v2.entities.managers.SFSRoomManager.createRoom(SFSRoomManager
.java:168)
com.smartfoxserver.v2.entities.SFSZone.createRoom(SFSZone.java:230)
com.smartfoxserver.v2.api.SFSApi.createRoom(SFSApi.java:608)
com.smartfoxserver.v2.api.SFSApi.createRoom(SFSApi.java:578)
kechuppserver.zone.KechuppZoneExtension.LaunchSession(KechuppZoneExtension.java:
663)
kechuppserver.zone.KechuppZoneExtension.OnLaunchRequest(KechuppZoneExtension.jav
a:623)
kechuppserver.zone.LaunchHandler.handleClientRequest(LaunchHandler.java:20)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.j
ava:192)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionCo
ntroller.java:137)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractControlle
r.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Although it throws this exception just as expected, it still creates the room! I dont want to create this room in case of such an exception.
While I did try putting a Try Catch block, for some reason this SFSExtensionException is not caught.
Following is the code:

Code: Select all

CreateRoomSettings csr = new CreateRoomSettings();
csr.setName(m_strKechuppRoomName);
csr.setMaxUsers(20);
csr.setMaxVariablesAllowed(10);
csr.setPassword("");
csr.setGame(false);
csr.setMaxSpectators(10);
try
{
RoomExtensionSettings res = new RoomExtensionSettings("KechuppFlash", "Main.ProofForJitesh");
csr.setExtension(res);
trace("\n no issues in creating extension________________");
}
catch(Exception e)
{
trace("Create extension failed:\n" + e.getMessage() + "\nStack Trace: \n" + e.getStackTrace());
return;
}

Room kechuppRoom = zone.getRoomByName(m_strKechuppRoomName);
assert(kechuppRoom == null);

try
{
kechuppRoom = this.getApi().createRoom(zone, csr, null);

}
catch (SFSCreateRoomException ex)
{
trace("Create Room Exception caught :" + ex.getMessage() + "\nstack trace :" + ex.getStackTrace());
//Logger.getLogger(KechuppZoneExtension.class.getName()).log(Level.SEVERE, null, ex);
trace("\nErrrrrrrrrrrrrrorr \n deleting room for SFSCreateRoomException");
this.getApi().removeRoom(kechuppRoom);
return;
}
catch (Exception ex)
{
//trace("Exception caught :" + ex.getMessage() + "\nstack trace :" + ex.getStackTrace());
Logger.getLogger(KechuppZoneExtension.class.getName()).log(Level.SEVERE, null, ex);
trace("\nErrrrrrrrrrrrrrorr \n deleting room for general Exception");
this.getApi().removeRoom(kechuppRoom);
return;
}


How do I handle the thrown SFSExtensionException in order to stop the creation of the room even when such an exception is thrown?

Thanks.
User avatar
Bax
Site Admin
Posts: 4330
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: SFSExtensionException

Postby Bax » 14 Jan 2013, 23:38

Actually I can't understand what you are trying to do. Either you need and have the Extension (and the error shouldn't be thrown) or you don't need it and create the Room without assigning it an Extension (and the error will disappear).
Paolo Bax
The SmartFoxServer Team
igjchhabria
Posts: 4
Joined: 04 Jan 2013, 08:14

Re: SFSExtensionException

Postby igjchhabria » 15 Jan 2013, 06:40

Hey Bax, thanks for replying.

OK, I will try and explain best what I am trying to achieve.

Well I needed a way to be able to Plug in Fresh Content(New Games) Dynamically into my Server side without having to RESTART SFS2X and thus losing dynamic data. For this the easiest way to imagine would be being able to dynamically create and load Zones for each such game, without needing a server restart. And if I am not wrong, I have read in the forums that this is not supported.
Please tell me I am wrong and there is another way to do this , that you know of ? :?

So just as an alternative, I was attempting to create Rooms dynamically, and assign them new Extension JAR's ( Game logic ) without having to restart the server. As a safety measure in order to prevent a failure in the case I am trying to attach an Extension JAR which does NOT EXIST or has been REMOVED, it should throw an exception. It does so by throwing the SFSExtensionException.

The problem here is that for some reason I am unable to catch this exception. If I can successfully catch this exception then I will be able to prevent the creation of this room in such a situation.

So based upon the code I have provide above, could you please tell me why I am unable to catch this exception. which is indeed being thrown?

NOTE: I have also provided the stack trace in which it is clear that the exception is being thrown in the Room Creation statement.

Code: Select all

kechuppRoom = this.getApi().createRoom(zone, csr, null);
User avatar
Bax
Site Admin
Posts: 4330
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: SFSExtensionException

Postby Bax » 15 Jan 2013, 09:54

You first assumption is not true. Using the AdminTool's Zone Configurator you can create a new Zone and launch it without restarting the server. The only limitation is that once the Zone is loaded, if you modify its settings you then have to restart the server.

Still I don't understand why you should create a Room and try to attach an Extension which doesn't exist. If your client tries to create a Room for a new game, in your tests you will exactly know that it requires an Extension, so before making the client available to the end users you should take care of deploying the Extension. Also, as we are talking about Room Extensions here, you don't even need to restart the server to deploy them.

About the exception not being caught, the reason is that the Exception doesn't "bubble" up the methods chain, but it is caught (and not re-thrown) in one of the methods you see listed in the stack trace. The reason is that this exception is not supposed to happen for the reason I tried to explain above. You don't try to launch an extension at runtime guessing its name. The Extension either exist or not, but in both cases you must know before trying to create the Room.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 14 guests