This is really useful – only recently found out how to do this and the benefit is enormous. Basically by a small configuration on JBoss’s startup configuration and a setting in Eclipse we can toggle breakpoints in our java code so that we can see where our code gets stuck and the JBoss processes that it goes through.
It takes about 5 minutes to do and once you’ve done it, it’ll make things much easier.
Start with JBoss, you’ll need to edit its run file (/jboss/bin/run.sh or run.bat) and un-comment line 87:
This tells JBoss which port to use to listen to for debug commands and it enables the JBoss’s remote debugging functionality.
Next we need to go to Eclipse and configure the debugger in there. If you go to the Window menu at the top and then go to Open Perspective and look for Debug (you may need to choose it from the Other menu). Once you’re in this perspective you can then setup an application profile for your debugger – look for the bug symbol on the top tool bar and select the Debug Configurations menu.
In here we choose to create a new Remote Java Application giving it a name and connection details for your JBoss server – so in my case its localhost. The port MUST be the same as the port expected in your JBoss run file, in this case by default its port 8787.
Ok thats it – debug should be setup. When you start JBoss it’ll pause waiting for you to start the debugger in Eclipse – just go back to the bug symbol and select your configuration you just made. JBoss will continue to load after this point and Eclipse should start showing you JBoss’s processes that it’s running.
Now we can add in breakpoints to our code allowing us to step through the code when its activated on JBoss – so if a user submits a form that calls in a bean which does x, y, z then we can see the logic that happens and if any issues occur – this is really useful for things like payment pipelines.
To toggle a breakpoint or to enable/ disable an existing one, just click in the left margin of your code window at the line you want to begin to step through. When this line gets processed JBoss will stop and you can then use the step through commands on the debug menu.
If you’re using the startDynamoOnJboss and run-in-place methods for your server then you can debug and fix your code theoretically very quickly and easily.