Page 2 of 3

Step by Step SFSx2 debugging

Posted: 14 Dec 2010, 11:54
by hamish
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.

Posted: 19 Dec 2010, 09:03
by lolandroll
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

Re: Guide: How to compile a .jar file for your extension

Posted: 22 Feb 2012, 11:54
by levancho
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 :

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

Posted: 14 Jan 2013, 03:45
by huhailong
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)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Re: Guide: How to compile a .jar file for your extension

Posted: 15 Jan 2013, 09:46
by Bax
huhailong, please don't double-post: viewtopic.php?p=66043#p66043

Re: Guide: How to compile a .jar file for your extension

Posted: 19 Apr 2013, 10:07
by FCrocetti
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:

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

Posted: 19 Apr 2013, 10:19
by Lapo
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

Re: Guide: How to compile a .jar file for your extension

Posted: 19 Apr 2013, 11:58
by FCrocetti
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

Re: Guide: How to compile a .jar file for your extension

Posted: 22 Apr 2013, 10:22
by Bax
The problem was the "Extension" suffix.
This is described in the doc too.

Re: Guide: How to compile a .jar file for your extension

Posted: 23 Apr 2018, 14:23
by AdrianG001
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

Re: Guide: How to compile a .jar file for your extension

Posted: 23 Apr 2018, 16:07
by Lapo
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

Re: Guide: How to compile a .jar file for your extension

Posted: 13 May 2018, 20:12
by houssein9
thank you so much!!! amazing.

Re: Guide: How to compile a .jar file for your extension

Posted: 15 Nov 2018, 18:17
by AdrianG001
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

Re: Guide: How to compile a .jar file for your extension

Posted: 16 Nov 2018, 08:23
by Lapo

Re: Guide: How to compile a .jar file for your extension

Posted: 16 Apr 2019, 13:25
by LordDawn
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.