You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Landis <dl...@gmail.com> on 2015/04/30 23:44:13 UTC

Debugging Tomcat Running in Vagrant using Port Forwarding

Hi,

I was wondering if anyone here might have any idea about this issue I was
having debugging my Tomcat app. I posted this question on Stack Overflow
several days ago but didn't get any responses (and it said it was only
viewed 15 times despite having the Java and Tomcat tags which is weird).
Anyway, here is the question, thanks:


I'm trying to attach my Eclipse debugger running on my Windows host to a
Tomcat 8 server running in my local Vagrant box (Virtual Box) running
CentOS 7.

Here is the full error from the Eclipse logs:

java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:179)
    at java.io.DataInputStream.readFully(DataInputStream.java:189)
    at java.io.DataInputStream.readFully(DataInputStream.java:163)
    at
org.eclipse.jdi.internal.connect.SocketTransportService.readHandshake(SocketTransportService.java:216)
    at
org.eclipse.jdi.internal.connect.SocketTransportService.access$7(SocketTransportService.java:212)
    at
org.eclipse.jdi.internal.connect.SocketTransportService$3.run(SocketTransportService.java:183)
    at java.lang.Thread.run(Thread.java:761)


The output from `vagrant up` seems correct (port 8000 is the debugging
port):

==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 8000 => 8000 (adapter 1)
    default: 8443 => 8443 (adapter 1)
    default: 22 => 2222 (adapter 1)

I can access my application (using https://localhost:8443/app) via a
browser from my host without issue; connecting the debugger is the issue.
The debugger is configured for a Remote Java Application with connection
properties:

Host: localhost
Port: 8000

Starting Tomcat of course displays the correct:

Listening for transport dt_socket at address: 8000


Based on the some other questions, the answer maybe have something to do
with configuring Tomcat to run on 0.0.0.0 instead of the default.

So I tried configuring the Connectors in Tomcat's server.xml with the line
address="0.0.0.0" but the result was the same.

Any other ideas about getting this to work? Also, assuming the answer is
something to do with changing the address to 0.0.0.0, why would I need to
do that to get the debugger to work if accessing the app via browser is
already fine on localhost:8443?

P.S. It is not a firewall issue.

Re: Debugging Tomcat Running in Vagrant using Port Forwarding

Posted by David Landis <dl...@gmail.com>.
On Thu, Apr 30, 2015 at 6:06 PM, Konstantin Kolinko <kn...@gmail.com>
wrote:

>
> Note that you have 2 firewalls, one on your own machine (to allow
> outgoing connections), another on the one running in virtual box (to
> allow incoming connections).
>
> Can you connect with a simple client, e.g. telnet?



Yeah firewall is definitely off in the VM and I temporarily turned off the
firewall in Windows as well. You mean `telnet localhost 8000` right? It
seems to work, as in just hangs whereas telnet to another random port
returns "Connect Failed" right away.

Re: Debugging Tomcat Running in Vagrant using Port Forwarding

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-05-01 3:29 GMT+03:00 David Landis <dl...@gmail.com>:
> On Thu, Apr 30, 2015 at 5:24 PM, Konstantin Kolinko <kn...@gmail.com>
> wrote:
>
>>
>> Have you started Tomcat in debug mode?
>> E.g. "./catalina.sh jpda start"
>>
>> See JPDA_ADDRESS option in catalina.sh source code.
>>
>
>
> Hi Konstantin. Yes I have. Like I noted in the original question Tomcat
> correctly outputs on startup:
>
> Listening for transport dt_socket at address: 8000

OK.

> P.S. It is not a firewall issue.

Note that you have 2 firewalls, one on your own machine (to allow
outgoing connections), another on the one running in virtual box (to
allow incoming connections).

Can you connect with a simple client, e.g. telnet?

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Debugging Tomcat Running in Vagrant using Port Forwarding

Posted by David Landis <dl...@gmail.com>.
On Thu, Apr 30, 2015 at 5:24 PM, Konstantin Kolinko <kn...@gmail.com>
wrote:

>
> Have you started Tomcat in debug mode?
> E.g. "./catalina.sh jpda start"
>
> See JPDA_ADDRESS option in catalina.sh source code.
>


Hi Konstantin. Yes I have. Like I noted in the original question Tomcat
correctly outputs on startup:

Listening for transport dt_socket at address: 8000

Re: Debugging Tomcat Running in Vagrant using Port Forwarding

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-05-01 3:13 GMT+03:00 David Landis <dl...@gmail.com>:
> On Thu, Apr 30, 2015 at 3:12 PM, David Marsh <dm...@outlook.com> wrote:
>
>> 8000 Is the HTTP port in development just in case you are using port
>> 808433 Is similar for HTTPS22 Is SSH port
>> Normally you define a free port in a user range say 9009, to be your debug
>> port.
>> Then you use a suitable java debugger to connect to that port.
>> I've never used vagrant, but it sounds like you'd also need that debug
>> port say 9009, to have port forwarding configured.
>> Once port forwarding is configured the debug port 9009 should be
>> accessible outside the VM.
>>
>
>
> Hi David -- thanks for the response. Port 8000 is definitely the default
> debugging port for Tomcat though and is what I've always used before when
> debugging locally. I suspect there is some additional configuration I need
> to do in Tomcat in order to debug while it is running in a Vagrant box
> using port forwarding.

Have you started Tomcat in debug mode?
E.g. "./catalina.sh jpda start"

See JPDA_ADDRESS option in catalina.sh source code.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Debugging Tomcat Running in Vagrant using Port Forwarding

Posted by David Landis <dl...@gmail.com>.
On Thu, Apr 30, 2015 at 3:12 PM, David Marsh <dm...@outlook.com> wrote:

> 8000 Is the HTTP port in development just in case you are using port
> 808433 Is similar for HTTPS22 Is SSH port
> Normally you define a free port in a user range say 9009, to be your debug
> port.
> Then you use a suitable java debugger to connect to that port.
> I've never used vagrant, but it sounds like you'd also need that debug
> port say 9009, to have port forwarding configured.
> Once port forwarding is configured the debug port 9009 should be
> accessible outside the VM.
>


Hi David -- thanks for the response. Port 8000 is definitely the default
debugging port for Tomcat though and is what I've always used before when
debugging locally. I suspect there is some additional configuration I need
to do in Tomcat in order to debug while it is running in a Vagrant box
using port forwarding.

RE: Debugging Tomcat Running in Vagrant using Port Forwarding

Posted by David Marsh <dm...@outlook.com>.
8000 Is the HTTP port in development just in case you are using port 808433 Is similar for HTTPS22 Is SSH port
Normally you define a free port in a user range say 9009, to be your debug port.
Then you use a suitable java debugger to connect to that port.
I've never used vagrant, but it sounds like you'd also need that debug port say 9009, to have port forwarding configured.
Once port forwarding is configured the debug port 9009 should be accessible outside the VM.

> Date: Thu, 30 Apr 2015 14:44:13 -0700
> Subject: Debugging Tomcat Running in Vagrant using Port Forwarding
> From: dlandis@gmail.com
> To: users@tomcat.apache.org
> 
> Hi,
> 
> I was wondering if anyone here might have any idea about this issue I was
> having debugging my Tomcat app. I posted this question on Stack Overflow
> several days ago but didn't get any responses (and it said it was only
> viewed 15 times despite having the Java and Tomcat tags which is weird).
> Anyway, here is the question, thanks:
> 
> 
> I'm trying to attach my Eclipse debugger running on my Windows host to a
> Tomcat 8 server running in my local Vagrant box (Virtual Box) running
> CentOS 7.
> 
> Here is the full error from the Eclipse logs:
> 
> java.net.SocketException: Connection reset
>     at java.net.SocketInputStream.read(SocketInputStream.java:179)
>     at java.io.DataInputStream.readFully(DataInputStream.java:189)
>     at java.io.DataInputStream.readFully(DataInputStream.java:163)
>     at
> org.eclipse.jdi.internal.connect.SocketTransportService.readHandshake(SocketTransportService.java:216)
>     at
> org.eclipse.jdi.internal.connect.SocketTransportService.access$7(SocketTransportService.java:212)
>     at
> org.eclipse.jdi.internal.connect.SocketTransportService$3.run(SocketTransportService.java:183)
>     at java.lang.Thread.run(Thread.java:761)
> 
> 
> The output from `vagrant up` seems correct (port 8000 is the debugging
> port):
> 
> ==> default: Preparing network interfaces based on configuration...
>     default: Adapter 1: nat
> ==> default: Forwarding ports...
>     default: 8000 => 8000 (adapter 1)
>     default: 8443 => 8443 (adapter 1)
>     default: 22 => 2222 (adapter 1)
> 
> I can access my application (using https://localhost:8443/app) via a
> browser from my host without issue; connecting the debugger is the issue.
> The debugger is configured for a Remote Java Application with connection
> properties:
> 
> Host: localhost
> Port: 8000
> 
> Starting Tomcat of course displays the correct:
> 
> Listening for transport dt_socket at address: 8000
> 
> 
> Based on the some other questions, the answer maybe have something to do
> with configuring Tomcat to run on 0.0.0.0 instead of the default.
> 
> So I tried configuring the Connectors in Tomcat's server.xml with the line
> address="0.0.0.0" but the result was the same.
> 
> Any other ideas about getting this to work? Also, assuming the answer is
> something to do with changing the address to 0.0.0.0, why would I need to
> do that to get the debugger to work if accessing the app via browser is
> already fine on localhost:8443?
> 
> P.S. It is not a firewall issue.