Last week I was getting one issue which was difficult to debug as the product was on EC2 instance. We were wasting lot of time as It was difficult to test and check the actual cause of issue. Later I decided to attach the Eclipse debugger to my target JVM which is running on some different(EC2 instance) machine with the help of PuTTy ( PuTTY is an SSH and telnet client).
Lets start with the steps :
1. Make sure your target JVM is started with these args:
-agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=n2. Create an SSH session into your PuTTy.
Open Putty, Add :
-- IP Address : "YOUR_TARGET_JVM_ADDRESS"
-- PORT : 22
-- Saved Sessions : your session name
-- Choose 'SSH' radio button and Save it.
3. After saving your server detail, in the same putty :
-- Goto Category -> SSH ->tunnels
-- source port :7000
-- Destination : ip:port <eg : 10.0.2.12:8001>
-- Click on 'Add' button
-- Again click on 'session' under category and save it.
-- Start the session once you are done with above settings by clicking on 'open' button.
4 . In Eclipse, Goto Run -> Debug Configuration -> Remote Java Application and Add :
-- Project : point to your project directory
-- Choose 'connection type' as 'Standard (Socket Attach)'
-- Host : localhost
-- Port : 7000 (Must be same as source port in PuTTy)
Now You are good to go to start with your remote debugging :)
Note : Sometime during Remote Debugging, You might get some error message like "Connection timeout". To fix the issue, Goto : Eclipse - > Windows -> Preferences -> Java ->Debug and set debugger timeout as some higher value.
Please let me know your comments/feedback, if any.
The problem is the sources, they are on a remote machine not where eclipse is. How do you solve this problem?
ReplyDelete