Possible to debug at runtime?

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

Moderators: Lapo, Bax

Post Reply
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Possible to debug at runtime?

Post 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.
Nisse Bergman
Raketspel
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
zood
Posts: 21
Joined: 02 Jul 2007, 17:29
Location: San Francisco
Contact:

Post 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. :)
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post 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 :)
Nisse Bergman
Raketspel
zood
Posts: 21
Joined: 02 Jul 2007, 17:29
Location: San Francisco
Contact:

Post 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
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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.
Lapo
--
gotoAndPlay()
...addicted to flash games
cevans
Posts: 15
Joined: 02 Jul 2007, 11:00

Post by cevans »

If you're modifying a Java package, you still have to do a hard restart of the server (./sfs restart) correct?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Yep, because the JVM classloader has to reload those classes
Lapo
--
gotoAndPlay()
...addicted to flash games
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post 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.
Nisse Bergman
Raketspel
zood
Posts: 21
Joined: 02 Jul 2007, 17:29
Location: San Francisco
Contact:

Post 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.
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

we got it working on win xp. i'll post a tutorial soon.
Nisse Bergman
Raketspel
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

thanks, would be really cool
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply