Guide: How to compile a .jar file for your extension
Step by Step SFSx2 debugging
Step by Step SFSx2 extension debugging
Hi just went through this process and thought i'd post it to make it easy for everyone, coz there are a few errors in the posts i've read.
I'm using eclipse IDE for java developers 3.6.1, and sfs2x server is running on my local machine, on windows xp
backup the bat file at
install folder/SFS2X/sfs2x.bat
edit the file with notepad and replace what's there with
@java -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y -cp "./;lib/*;lib/Jetty/*;extensions/__lib__/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main $1 $2 $3
go to eclipse
run/debug configurations...
right click Remote Java Application and choose Add...
make sure the connection properties are set to
host: localhost
Port: 8787
double click the bat file you edited.
the cmd window should appear and say
Listening for transport dt_socket at address 8787
press the little green bug in eclipse to start the debugging session ( i found i had to click the little arrow next to it and select my extension name)
when you start the debugging session the SFSx2 server should start as normal
set some breakpoints in your extension code.
and enjoy.
Hi just went through this process and thought i'd post it to make it easy for everyone, coz there are a few errors in the posts i've read.
I'm using eclipse IDE for java developers 3.6.1, and sfs2x server is running on my local machine, on windows xp
backup the bat file at
install folder/SFS2X/sfs2x.bat
edit the file with notepad and replace what's there with
@java -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y -cp "./;lib/*;lib/Jetty/*;extensions/__lib__/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main $1 $2 $3
go to eclipse
run/debug configurations...
right click Remote Java Application and choose Add...
make sure the connection properties are set to
host: localhost
Port: 8787
double click the bat file you edited.
the cmd window should appear and say
Listening for transport dt_socket at address 8787
press the little green bug in eclipse to start the debugging session ( i found i had to click the little arrow next to it and select my extension name)
when you start the debugging session the SFSx2 server should start as normal
set some breakpoints in your extension code.
and enjoy.
Last edited by hamish on 24 Jan 2011, 15:54, edited 1 time in total.
-
- Posts: 7
- Joined: 30 Nov 2010, 17:15
Does enyone can tell how to recompile the expamles from that page:
http://docs2x.smartfoxserver.com/Develo ... se-recipes
becouse I wanted to chage database name for something else and changing it in java filese doesn't seems to work
#########################
Nevermind -
i saw that lapo add new tutorial in the docs
http://docs2x.smartfoxserver.com/Develo ... extensions
That would help
http://docs2x.smartfoxserver.com/Develo ... se-recipes
becouse I wanted to chage database name for something else and changing it in java filese doesn't seems to work
#########################
Nevermind -
i saw that lapo add new tutorial in the docs
http://docs2x.smartfoxserver.com/Develo ... extensions
That would help
Re: Guide: How to compile a .jar file for your extension
just want to contribute my approach.
I use executable instead of bat file so in that case editing : sfs2x-standalone.vmoptions was sufficient for me to get debugger working.
I added :
and just to make sure debugger is working, you should see something like his in startup console (at the begining) :
I use executable instead of bat file so in that case editing : sfs2x-standalone.vmoptions was sufficient for me to get debugger working.
I added :
Code: Select all
-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
and just to make sure debugger is working, you should see something like his in startup console (at the begining) :
Code: Select all
Listening for transport dt_socket at address: 8787
Re: Guide: How to compile a .jar file for your extension
does all java class for a zone need to put to one xxxExtension.jar ?
because i have a problem: i create a class MyOSExtension extends OpenSpaceExtension, this class will create all room and other data when sfs2x start,
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, so it will create all room again but failed.
if class MyOSExtension runned again, 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)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
because i have a problem: i create a class MyOSExtension extends OpenSpaceExtension, this class will create all room and other data when sfs2x start,
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, so it will create all room again but failed.
if class MyOSExtension runned again, 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: Guide: How to compile a .jar file for your extension
huhailong, please don't double-post: viewtopic.php?p=66043#p66043
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: Guide: How to compile a .jar file for your extension
Hello,
I'm having issues on listing in the zone extension list my custom jars compiled from Netbeans 7.1, I don't succeed neither on SFS2X for OSX 10.8 nor for Windows 7. I have to say that I'm completely newbie in Java (but I'm a senior programmer in a bunch of other languages so it's not a problem), but I followed these steps and the video tutorial though my extension is not listed.
I don't succeed to list neither a "hello world" extension like this:
Since moving your TrisExtension.jar to my folder in /extensions makes my folder to be correctly listed in Zone manager (but my classes are not listed in the Main classes), I can only suppose it has something to do with how I'm compiling.
You can find the project source (very small, it is the example above) here, it contains the Netbeans project folder so you can see both source and the compiled jar (in the folder /dist). By the way in the project settings I have Source/Binary Format=JDK6 and Encoding=UTF-8, you can take a look at the screenshot here.
Thank you in advance, best regards.
I'm having issues on listing in the zone extension list my custom jars compiled from Netbeans 7.1, I don't succeed neither on SFS2X for OSX 10.8 nor for Windows 7. I have to say that I'm completely newbie in Java (but I'm a senior programmer in a bunch of other languages so it's not a problem), but I followed these steps and the video tutorial though my extension is not listed.
I don't succeed to list neither a "hello world" extension like this:
Code: Select all
import com.smartfoxserver.v2.extensions.SFSExtension;
public class testSfsExtension extends SFSExtension {
@Override
public void init() {
trace("***[ Test Sfs Extension loaded ]***");
}
}
Since moving your TrisExtension.jar to my folder in /extensions makes my folder to be correctly listed in Zone manager (but my classes are not listed in the Main classes), I can only suppose it has something to do with how I'm compiling.
You can find the project source (very small, it is the example above) here, it contains the Netbeans project folder so you can see both source and the compiled jar (in the folder /dist). By the way in the project settings I have Source/Binary Format=JDK6 and Encoding=UTF-8, you can take a look at the screenshot here.
Thank you in advance, best regards.
Re: Guide: How to compile a .jar file for your extension
Hi,
a few suggestions.
1- Please do use a package declaration in your classes
2- Please always start a class name with a capital letter (TestSfsExtension not testSfsExtension)
3- Follow the SFS2X jar naming convention: <AnyName>Extension.jar, e.g.: MyCoolExtension.jar, GameExtension.jar, PokerExtension.jar etc...
Thanks
a few suggestions.
1- Please do use a package declaration in your classes
2- Please always start a class name with a capital letter (TestSfsExtension not testSfsExtension)
3- Follow the SFS2X jar naming convention: <AnyName>Extension.jar, e.g.: MyCoolExtension.jar, GameExtension.jar, PokerExtension.jar etc...
Thanks
Re: Guide: How to compile a .jar file for your extension
Great! It worked, I don't know if it was because of first capital letter renaming on the extension class or the suffix "Extension" to jar filename or both, however now they're listed and I can continue testing! It's probably useful to append these hints to the topic message.
Thanks
Thanks
Re: Guide: How to compile a .jar file for your extension
The problem was the "Extension" suffix.
This is described in the doc too.
This is described in the doc too.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 3
- Joined: 20 Apr 2018, 15:53
- Contact:
Re: Guide: How to compile a .jar file for your extension
FCrocetti wrote:Great! It worked, I don't know if it was because of first capital letter renaming on the extension class or the suffix "Extension" to jar filename or both, however now they're listed and I can continue testing! It's probably useful to append these hints to the topic message.
Thanks
which version of netbeans do i need to install?
Java SE, JavaFX, Java, Ruby, C/C++, PHP or All?
Regards,
Adrian Gates
Sr. Developer - Apps4Rent
Last edited by AdrianG001 on 15 Nov 2018, 18:08, edited 1 time in total.
Re: Guide: How to compile a .jar file for your extension
Hi,
the JavaSE version is fine for developing with SFS2X.
The other stuff can be useful if you plan to develop for those platforms, otherwise it will just take more installation space.
Cheers
the JavaSE version is fine for developing with SFS2X.
The other stuff can be useful if you plan to develop for those platforms, otherwise it will just take more installation space.
Cheers
Re: Guide: How to compile a .jar file for your extension
thank you so much!!! amazing.
-
- Posts: 3
- Joined: 20 Apr 2018, 15:53
- Contact:
Re: Guide: How to compile a .jar file for your extension
Is there any alternative for netbeans which is almost similar to netbeans. I`m facing difficulties in installing netbeans on my new citrix vdi system
Regards,
Adrian Gates
Regards,
Adrian Gates
Last edited by AdrianG001 on 21 Nov 2018, 15:02, edited 1 time in total.
Re: Guide: How to compile a .jar file for your extension
I'm following the guide, I have the latest Java and Eclipse, and have written a demo hello world extension, but when I add the Jar file into the extensions/MyExtension folder, and restart the clean install of smartfox, it crashes out. I can't find any log that shows an error as to why this happens. Remove the extension jar file and it starts up fine (though issues a warning that the MyExtension folder contains no jar file.
I guess this means that there's something wrong with my jar file, but I'm unsure what, as there are no errors or warnings issued that I can see. The code it the same as in the tutorial. Really very simple. Pretty sure this is just a beginners issue, and I'm missing something or have something wrong.
I guess this means that there's something wrong with my jar file, but I'm unsure what, as there are no errors or warnings issued that I can see. The code it the same as in the tutorial. Really very simple. Pretty sure this is just a beginners issue, and I'm missing something or have something wrong.
Who is online
Users browsing this forum: No registered users and 104 guests