2

I am attempting to Debug a simple Java Server Application hosted on localhost on any given port. Within Eclipse I run it in debug mode to wait on an incoming connection. When I run my a browser to retrieve data from the server I get nothing. If I run the Application outside of Eclipse, everything is fine and my pages are served.

Is there anything I need to do in Eclipse to enable ports or anything?

I saw this post: How does Eclipse debug code in an application server?

but that is only informational. Any help would be great.

Community
  • 1
  • 1
jiveturkey
  • 2,484
  • 1
  • 23
  • 41

2 Answers2

2

To debug applications that run on another JVM or even on another machine, start them with these flags:

java -Xdebug -Xnoagent \ 
-Djava.compiler=NONE \ 
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 

Enter the hostname and port to connect for debugging:

 Run → Debug Configuration... menu

Create a new debug configuration of the Remote Java Application type.
This configuration allows you to enter the hostname and port for the connection.

1

Eclipse Settings:
1.Click the Run Button
2.Select the Debug Configurations
3.Select the “Remote Java Application”
4.New Configuration
a) Name : GatewayPortalProject
b) Project : GatewayPortal-portlet
c) Connection Type: Socket Attach
d) Connection Properties:
i) localhost ii) 8787

For JBoss:

1.Change the /path/toJboss/jboss-eap-6.1/bin/standalone.conf in your vm as follows: Uncomment the following line by removing the #:

JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

For Tomcat :

In catalina.bat file :

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

Then you need to set breakpoints in the Java classes you desire to debug.

Hope this helps.

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108