Page 1 of 1

Possible to debug at runtime?

Posted: 27 May 2007, 12:43
by potmo
Im no java pro but i'd like to lern.

Is there any way to debug my java extensions in runtime? Like setting debugstops in eclipse and se all values?

Just like you do in flash.

Posted: 27 May 2007, 20:09
by Lapo
In order to debug in eclipse you should be able to run the extension directly in the IDE. It's not possible to debug the extension while running in the server but you could add a main() method to the extension and run it as a standalone java app to do some testing and debugging.

Another effective way to test the extension is using JUnit --> http://www.junit.org/index.htm

Posted: 02 Jul 2007, 18:14
by zood
Lapo wrote:In order to debug in eclipse you should be able to run the extension directly in the IDE. It's not possible to debug the extension while running in the server but you could add a main() method to the extension and run it as a standalone java app to do some testing and debugging.
has anybody done this successfully? I have been working on a server extension in java (programming in eclipse, building and copying to remote server over and over) and remote or local debugging would be very helpful. :)

Posted: 02 Jul 2007, 21:01
by potmo
zood wrote:has anybody done this successfully?
I havent but if someone have please let me know how to do it.
I have now written all my code in AS2 but for performance purposes id like to convert the code to JAVA. For that it would be great to "runtime" debug the extensions. Its a hell compiling and copying files to the server all the time.

B.T.W and O.T.
When researching for the convertion to JAVA I saw that the JAVA SS-API has a lot more properties and functions than the flash SS-API. I find this a bit strange but i like it :)

Posted: 02 Jul 2007, 21:24
by zood
I figured this out shortly after posting. It turns out it IS possible to do some remote debugging of java extensions.

I loosely followed the instructions in this tutorial:

http://www.onjava.com/pub/a/onjava/2005 ... tml?page=1

however in this case, obviously we are using smartfoxserver and not jboss. OK!

find the wrapper.conf file in your server/conf directory and open it in an editor. find this line:

Code: Select all

wrapper.java.additional.3=-Djava.util.logging.config.file=logging.properties
and add these lines directly below:

Code: Select all

wrapper.java.additional.4=-Xdebug
wrapper.java.additional.5=-Xnoagent
wrapper.java.additional.6=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
now if you follow the rest of the tutorial, you should be able to attach eclipse to your smartfoxserver and debug your extension. using this technique I was able to set breakpoints and inspect variables, etc... when you are not debugging you should probably disable these lines with the "#" character at the beginning.

HTH

Posted: 03 Jul 2007, 06:50
by Lapo
Thanks Zood,
very useful tip :)
For that it would be great to "runtime" debug the extensions. Its a hell compiling and copying files to the server all the time.
You guys can relieve the pain using Ant which usually comes embedded with Eclipse. With Ant you can automate the entire process of copying the files from your dev environment to your remote server, wheter it's another machine in the LAN or through FTP etc...

I have experimented with automating this using Python and it's also very effective, I did a simple script that monitors my build folder and transfers all the changes to the SFS machine as soon as a class file is modified.

Posted: 03 Jul 2007, 23:43
by cevans
If you're modifying a Java package, you still have to do a hard restart of the server (./sfs restart) correct?

Posted: 04 Jul 2007, 06:01
by Lapo
Yep, because the JVM classloader has to reload those classes

Posted: 25 Sep 2007, 12:00
by potmo
zood wrote:I figured this out shortly after posting. It turns out it IS possible to do some remote debugging of java extensions.
I've been trying to get this to work but i can't. Anyone got a better turorial on how to do this? It would be great to debu my extensions and put breakpoints and stuff.

Posted: 25 Sep 2007, 17:04
by zood
potmo, is your server on windows or linux? for some reason I could only get this to work against a linux server, maybe the arguments are different if the JVM is running on windows? also you may want to check your network settings, firewall, etc.

Posted: 25 Sep 2007, 17:25
by potmo
we got it working on win xp. i'll post a tutorial soon.

Posted: 01 Oct 2007, 08:53
by Lapo
thanks, would be really cool