Many Java developers doesn't realize about remote debugging capability, thus make their life stay in trouble when their program start acting weirdly when it's running outside their development environment. Almost all of them start to add special code to print some useful information in some place to diagnose the problem. But is that the best way to do? In my aspect, the easiest way to spot the problem is using JDPA capability to debug it without touching source code...
To do that, these few steps are required.
1) Compile Java source code with debugging information attached.
2) Allow remote debugging in target JVM
3) Start remote debugging from supported client (Eclipse is perfect for me)
First step - Compile with debug information.
Go to project->properties->Java Compiler then select the check box as in the pic below
Next step - Deploy the compiled classes then enable remote debug in execution JVM
Build your application which contains debug information from first step then deploy it to target execution environment, then add the following execution arguments.
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address="8000" -jar TechTemp.jar
Note: The target VM will be suspended until the debugger connects, just to ensure the program will not be executed pass the spot that you need to debug :)
The last step - Start debugger to attach to remote JVM
Go to run->debug configurations then select Remote Java Application

Change config to fit with your application then hit the Debug button and enjoy debugging!
Acronym:JDPA - Java Platform Debugger Architecture