[JAVA] Remote debug connection to tomcat running multiple times on CentOS7

As far as I googled lightly, I could not find a way to set remote debugging on tomcat under multi-instance operation, so it also serves as a reminder.

environment

Version
CentOS
Tomcat

background

--Usually, remote debug setting of tomcat is done by enabling jpda (Java Platform Debugger Architecture) from catalina.sh.

catalina.sh jpda start

--But when you install tomcat7 with yum on CentOS7, catalina.sh is not generated. In other words, this method cannot be used ヽ (´ ー `) ノ

Premise

--Ports should be available in advance

--Assuming this content (especially [Manage tomcat service]). It is explained in great detail

Reference memo / Note about Apache Tomcat package of CentOS 7

Coping

    1. service file for tomcat __ / usr / lib / systemd / system / [[email protected]] __, add the following description to the file specified in the item [EnviromentFile]

bash:/etc/sysconfig/EnviromentFile[1...n]


JAVA_OPTS = '[Original content] -agentlib:jdwp=transport=dt_socket,address=[port number],server=y,suspend=n'
JPDA_SUSPEND=y
JPDA_ADDRESS=[IP of this host]:[port number]
  1. When operating with multiple instances, there should be multiple files, so add them to all files. Be careful of duplicate port numbers

    1. restart tomcat
systemctl restart [[email protected]]
  1. Make sure that you can connect to the configured port remotely. OK if there is no "Connection refused"
telnet [IP set earlier] [The port number you set earlier]
  1. When connecting from Eclipse, select the menu [Run]-> [Debug Configuration]-> [Remote Java Application], connection type [Standard (socket connection)], host [IP set earlier], port [Port set earlier]. Set the [Number] and press the [Debug] button.

Commentary

--What you are doing is just adding the debug setting option string added in catalina.sh to the option setting part of EnviromentFile.

――As mentioned on the above page, I was disappointed because the environment is very different from other distributions.

reference

-Allow remote debugging of Tomcat8

-Sun VM calling options (Oracle official)

Recommended Posts

Remote debug connection to tomcat running multiple times on CentOS7
How to deploy Laravel on CentOS 7
Upgrade from MYSQL5.7 to 8.0 on CentOS 6.7
Steps to install MySQL 8 on CentOS 8
Steps to install devtoolset-6 on CentOS 7
Change JDK and Tomcat versions on CentOS
How to remote debug Java 9 or later
How to install beta php8.0 on CentOS8
Relative path when running tomcat on eclipse
I tried to build AdoptOpenjdk 11 on CentOS 7