This feature really helps me to find some bugs in my code in an easy way. I have tried this for WSO2 appfactory server and its no meter it will work for any of WSO2 products and other servers too.
First you need to start the server in debug mode. For WSO2 carbon server go to bin directory and type following command in the terminal.
./wso2server.sh –debug 5005 . You can use different port number for this.
Next place some debug points in your code and set up the debug configurations. right click on your project and go to Debug as and click on Debug Configurations. Next click on Remote Java Application which is in the left side of the debug configuration window as shown in the figure bellow. Then Apply the changes and click debug.