Reference to files in webapp from java sfs extensions

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

GrinReaper
Posts: 43
Joined: 06 Aug 2012, 09:48

Reference to files in webapp from java sfs extensions

Postby GrinReaper » 06 Aug 2012, 09:53

I'm referencing a class included in the web service (deployed as a war via jetty on SFS) in a java extension. The extension is unable to locate the class giving the following error:

Code: Select all

jvm 1    | Exception in thread "SmartFoxServer" java.lang.NoClassDefFoundError: com/skilrock/rummy/service/GameMgmtService
jvm 1    |    at java.lang.Class.getDeclaredConstructors0(Native Method)
jvm 1    |    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
jvm 1    |    at java.lang.Class.getConstructor0(Class.java:2699)
jvm 1    |    at java.lang.Class.newInstance0(Class.java:326)
jvm 1    |    at java.lang.Class.newInstance(Class.java:308)
jvm 1    |    at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.loadExtension(ExtensionHandler.java:117)
jvm 1    |    at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.createExtension(ExtensionHandler.java:207)
jvm 1    |    at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.createExtension(ExtensionHandler.java:189)
jvm 1    |    at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.parse_Extensions(ExtensionHandler.java:649)
jvm 1    |    at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer.java:2085)
jvm 1    |    at it.gotoandplay.smartfoxserver.lib.ConfigReader.parse_Zones(ConfigReader.java:806)
jvm 1    |    at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:174)
jvm 1    |    at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:339)
jvm 1    |    at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:607)
jvm 1    | Caused by: java.lang.ClassNotFoundException: com.skilrock.rummy.service.GameMgmtService
jvm 1    |    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
jvm 1    |    at java.security.AccessController.doPrivileged(Native Method)
jvm 1    |    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
jvm 1    |    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
jvm 1    |    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
jvm 1    |    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
jvm 1    |    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
jvm 1    |    ... 14 more


Is it possible to do this or am I doing something wrong here?

Thanks :)
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Reference to files in webapp from java sfs extensions

Postby Lapo » 07 Aug 2012, 11:55

They are different classloaders (Jetty and SmartFoxServer) so it won't work. SFS needs the libraries in its lib/ folder in order to be seen at the classpath level.
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
GrinReaper
Posts: 43
Joined: 06 Aug 2012, 09:48

Re: Reference to files in webapp from java sfs extensions

Postby GrinReaper » 07 Aug 2012, 12:02

So, if a user enters the parameters of a room via a jsp running on the web service, there is no way to directly access those from the extension to create a room with those parameters? Or, is there some workaround (without involving the use of a database to store those parameters).
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Reference to files in webapp from java sfs extensions

Postby Lapo » 28 Aug 2012, 07:52

There is an easier way which is calling the API directly from the servlet.
You collect the parameters in the servlet, create the RoomSettings object and finally call the SFSAPI.createRoom(...) method.

If you don't want to duplicate code in your Extension and in the servlet you can deploy a Class that takes care of the Room creation under the extensions/__lib__/ folder. This way it can be seen both by your Extensions and the servlet, and you avoid the code duplication.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 67 guests