I am unable to setup remote debugging for my Tomcat 6 web app on Ubuntu 12.04.
I have tried the solutions offered in the following related question: Remote debugging Tomcat with Eclipse
The highest ranked solution says I should open catalina.sh and change the JPDA_OPTS variable to: JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Then start tomcat using jpda: catalina.sh jpda start
I checked my app at localhost, port 8000 and got an 'Unable to connect error'.
The next best solution was:
In catalina.bat file please modify the below.
Step 1: CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
Step 2: JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Step 3: Run Tomcat from command prompt like below: catalina.sh jpda start
When I checked localhost, port 8000 I got the same 'Unable to connect error'. Attempting to connect to the tomcat debugger through Eclipse after both of these attempts gave me an error:
Failed to connect to remote VM. Connection refused.
Connection refused
This made me think that port 8000 might be closed so I ran an nmap command to show which ports on my 'localhost' were open. It returned the following:
ryan@ryan-K53E:~$ nmap -v localhost
Starting Nmap 5.21 ( http://nmap.org ) at 2013-04-15 22:12 BST
Initiating Ping Scan at 22:12
Scanning localhost (127.0.0.1) [2 ports]
Completed Ping Scan at 22:12, 0.00s elapsed (1 total hosts)
Initiating Connect Scan at 22:12
Scanning localhost (127.0.0.1) [1000 ports]
Discovered open port 80/tcp on 127.0.0.1
Discovered open port 3306/tcp on 127.0.0.1
Discovered open port 53/tcp on 127.0.0.1
Discovered open port 22/tcp on 127.0.0.1
Discovered open port 8080/tcp on 127.0.0.1
Discovered open port 631/tcp on 127.0.0.1
Completed Connect Scan at 22:12, 0.02s elapsed (1000 total ports)
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00028s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
80/tcp open http
631/tcp open ipp
3306/tcp open mysql
8080/tcp open http-proxy
Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds
This looks to confirm that port 8000 is closed so I defined 'tomcat-debug' as a service in the '/etc/services' file like so:
tomcat-debug 8000/tcp # Remote tomcat debugging
Then tried to open port 8000 with iptables using the following command:
sudo iptables -A INPUT -p tcp --dport tomcat-debug -j ACCEPT
This doesn't seem to have made a difference as nmap is still showing the same list of open ports as before. Any help here would be greatly appreciated.