Reputation: 10308
I understand that this is possible to do with the Ultimate Edition, but is there a way to debug these applications locally in the Community Edition?
Upvotes: 30
Views: 23252
Reputation: 1139
@AmirHd's answer was very helpful. I'm using Idea Community version and you actually don't need to install any Tomcat plugins at all.
catalina.sh
(in Linux) file which is located in the Tomcat bin directory.JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
Run
menu. Select Edit Configuration
option.Remote
from the drop down.Listening for transport dt_socket at address: 5005
Alt + Shift + F9
or Run -> debug
option.No plugins at all.
Upvotes: 1
Reputation: 1483
put
set "JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
line in catalina.bat then open command line in tomcat directory and run
catalina.bat run
Also note: I had to choose port 5005 because the default one in configuration settings in my IntelliJ was not editable.
Upvotes: 0
Reputation: 53
AmirHd answer is very helpful, but I had one more problem. When I changed JAVA_OPTS server wouldn't shutdown as in this post: Tomcat failed to shutdown I resolved this by changing
JAVA_OPTS
to
CATALINA_OPTS
Upvotes: 1
Reputation: 10308
If you have worked with IntelliJ Ultimate edition you have seen that it is possible to add a Tomcat configuration where you can both debug or run your Tomcat container from within IntelliJ. It is possible to get your IntelliJ Community version to do the same thing for you with a little bit of extra settings.
This is a remote monitoring and management tool for Tomcat. JMX related settings is not needed to enable your debugging. Although it can be useful for monitoring purposes through JConsole (read more).
You instance of Tomcat must be already up and running for the Community version to be able to attach itself to the Tomcat process. While your tomcat will be running on a port (Tomcat default is 8080), you also need to setup another port for the debugger to attach itself to your running version of Tomcat (9999 in our example).
Settings include changes you need to make to your Tomcat and configurations you need to do on your IntelliJ community edition.
Please follow the order in changes.
Stop your Tomcat if it is running in your Tomcat bin folder through:
./shutdown
or ./catalina stop
Add the following line to your catalina.sh file under the commented JAVA_OPTS set statement:
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999"
HINT: I have used
JAVA_OPTS
notCATALINA_OPTS
as the comments in catalina.sh suggests it is preferred to useJAVA_OPTS
. However, it is possible to useCATALINA_OPTS
in a similar manner to enable the debugging.
./catalina.sh start
After click on debug button in your IntelliJ Community edition your debug section should open with the following line in its Console area:
Connected to the target VM, address: 'localhost:9999', transport: 'socket'
Upvotes: 33