Debug J2EE Applications on IntelliJ Community Edition and Tomcat8 (running as a service) - windows

I've searched a lot on Remote Debugging a REST APIs written in Java using IntelliJ IDEA Community Edition.
My Setup:
Windows 10
Tomcat installed as a windows service
Java 8
Intellij Community IDE
Finally after some googling and sifting through SO, found a solution that works. Posting it below.

Part I. Running Tomcat in Debug Mode
When running Tomcat8 as a service
Open {$TOMCAT_HOME}\bin\Tomcat8w.exe
Under Java > Java Options add the following lines to enable the debug port 8001:
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001
Restart the Tomcat Service
Part II. Attaching IntelliJ IDEA Remote Debugger
Create a new Run Configuration using the Remote Template.
Under Configuration > Settings Change the Port to 8001
Run the new config by clicking on the debug icon and IDEA will connect to the debug port of Tomcat
Credits:
How to remotely debug the webapplication running on tomcat service?

Related

Tomcat Remote Deployment

I want to deploy a WAR from my local windows box to a remote tomcat machine
I am using the following command from Postman
http://10.248.9.104:8080/manager/text/deploy?path=/greeting1&war=file:///C:/Users/jagaran.das/Documents/work/AIP/Automation/workspace/gs-rest-service-master/initial/target/gs-rest-service-0.1.0.war
Also I have tried lot of options.
My main requirement is to control deployment to 100 tomcat server from a central location. I was thinking of using tomcat manager remote deployment way but I am not able to do. Please help
Tomcat Version is Tomcat 7.0.78

intellij idea 14 cannot connect to debug tomcat7 service

Ok, I think I tried everything before I am posting this question. Please tell me, what I am (Still) missing. I keep getting "unable to connect" exception (unable to connect hostname:6012), I changed from default port 1099 and it still didn't help.
version of IntelliJ 14.0.2
Tomcat 7.0.52
Tomcat is running as a service so, I configured on the UI interface of tomcat.exe (java tab) the following JAVA_OPTs
-Xdebug
-Xrunjdwp:transport=dt_socket,address=57497,server=y,suspend=n
-javaagent:C:\Users\username\.IntelliJIdea14\system\groovyHotSwap\gragent.jar
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=6012
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcatalina.home=C:\Tomcat 7.0
-Dcatalina.base=C:\Tomcat 7.0
-XX:MaxPermSize=512m
I made sure the port 57497 is open (open the firewall and telnet).
And on IntelliJ, I made a remote server connection. Please find attached
pictures. Both intellij and tomcat are running on the same system. I have a static dns setup. sometimes i get connection timedout exception.
server tab
connection tab
Here's my config.
Tomcat JAVA_OPTs to enable remote debugging:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5007
In IntelliJ, I don't use the Configuration-Type 'Tomcat'. In my case 'Remote' works pretty well (I would post an image but I ain't got 10 reputation...). You only need to configure your host and port on the config sheet.
I use IntelliJ 14.0.3 and I had the same issue, though with Jetty. Switching to using the remote instead of jetty -> remote worked. I'm guessing they're both supposed to work differently. I just haven't figured out why there are two different options to remote debug.

Unable to debug tomcat server using eclipse

I'm using:
Spring Tool Suite Version: 3.2.0.RELEASE
Tomcat v7.0.42
When I just run my tomcat server everything is fine but I'm unable to debug it even locally. It produces following error:
Startich Apache Tomcat v7.0.42 at localhost has encoutered a problem.
Server Apache Tomcat v7.0.42 bat localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.
I've tried the following:
increase the timeout.
remove all the apps before starting the debugging.
install new instance of tomcat (the only configuration that I've did on fresh install is turning on Use Tomcat installation and Never publish automatically).
But it didn't help, I still can only run the tomcat, without the debug option. Does anyone know how to make this debugging work?
When I've used new, clear workspace for Spring Tool Suite, debugging started to work.
Cheers,

tomcat debugging

I am working on a project where the backend code is in Java.
I want to debug this code and am running tomcat in the debug mode correctly .
I have the Java code in Eclipse where I set up a new debug config for Remote Java Application and start the debugging.It shows no error but it is not breaking at the breakpoint.
So the Tomcat Webapps folder has only a copy of the Servlet classes and my Java code is in a folder at some other place.
Is this the reason that I am not being able to link them properly
You have to start tomcat with the JPDA options in order to debug remotely. Under *nix, issue "catalina jpda start" instead of "catalina start".
If you want to do a remote debug to figure out a problem in code, then your code locally must be the same. Also remember to connect to the correct port, 8000, I believe.

How to enable remote debugging in JBOSS 5?

How do you enable remote debugging in JBoss 5? The usual line from JBoss 4:
set JAVA_OPTS= -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
As can be found in other answers like this do not seem to work. The server never suspends. Googling "jboss 5 remote debug" doesn't bring up anything in the JBoss docs. Did something change from JBoss 4? How can I remotely debug my JBoss 5 server from eclipse?
You have suspend=n in your options. Change this to suspend=y.
Or is the line you posted not the one you're using with JBoss?
We have to do 2 changes to debug remote java application that is running in JBoss
Configure in JBoss
Creating remote debugger in in eclipse
Open run.conf.bat(windows) or run.conf(Linux) file in JBoss bin folder.
go to the below lines
`# Sample JPDA settings for remote socket debugging`
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
and remove hash in JAVA_OPTS
# Sample JPDA settings for remote socket debugging
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
Restart the server if it is started.
2. In Eclipse, Run -> Debug configuration -> Remote Java Application and create a new.
Note that you have to give port that is mentioned in run.conf.bat file

Resources