java - Tomcat 7 和 CentOS 7 中的远程调试

标签 java tomcat centos centos7

我正在尝试设置从 IntelliJ 到 Tomcat 的远程调试,但暂时忘记 IntelliJ,因为我还没有开始使用它。我最初尝试在服务器上设置它,我尝试设置 tomcat 以便它可以接受这些连接,但是当我添加 jdwp 标志/参数时,tomcat 不会启动并出现以下错误。

May 27 23:02:58 lab5 server: ERROR: transport error 202: bind failed: Permission denied
May 27 23:02:58 lab5 server: ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)    
May 27 23:02:58 lab5 server: JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
May 27 23:02:58 lab5 systemd: tomcat.service: main process exited, code=exited, status=2/INVALIDARGUMENT        
May 27 23:02:58 lab5 systemd: Unit tomcat.service entered failed state.
May 27 23:02:58 lab5 systemd: tomcat.service failed.

我尝试了多种方法。

-Xdebug -Xrunjdwp:transport=dt_socket,address=myec2privateip:2345,server=y,suspend=n \
-agentlib:jdwp=transport=dt_socket,address=myec2privateip:2345,suspend=y,server=n \
-agentlib:jdwp=transport=dt_socket,address=myec2privateip:2345,suspend=y,server=y \
-agentlib:jdwp=transport=dt_socket,address=myec2privateip:2345,suspend=n,server=y \
-agentlib:jdwp=transport=dt_socket,address=myec2privateip:2345,suspend=n,server=n \
-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n
-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=myec2privateip:2000,suspend=n \
# JPDA_ADDRESS=myec2privateip:32702
# JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=32702"
-agentlib:jdwp=transport=dt_socket,server=y,address=8000 \
-agentlib:jdwp=transport=dt_socket,server=y,address=*:8000,suspend=n \
JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
agentlib:jdwp=transport=dt_socket,address=localhost:39621,suspend=n,server=y -Xdebug
-Xdebug -agentlib:jdwp=transport=dt_socket,address=2345,server=y,suspend=n -Djava.security.debug=all

对于我上面尝试过的端口,它们上没有任何运行。这不是连接超时的问题,也不是防火墙等问题。

Tomcat 位于具有以下 CentOS AMI“CentOS Linux 7 x86_64 HVM EBS 1602”的 AWS EC2 实例上

我安装的Tomcat来自yum,“tomcat-7.0.92-1.el7.noarch”

Java版本

  • OpenJDK 版本“1.8.0_242”
  • OpenJDK 运行时环境(内部版本 1.8.0_242-b08)
  • OpenJDK 64 位服务器虚拟机(版本 25.242-b08,混合模式)

如果我删除已添加的参数,Tomcat 将工作得非常好。

为什么会发生此错误,以及为什么我无法让 Tomcat 启动其中任何一个?

我主要在 JAVA_OPTS 下的 /etc/sysconfig/tomcat 中进行设置,但也尝试过其他位置。

最佳答案

对于在 Centos7 上执行此操作并遇到相同问题的其他人,在尝试了一百万次之后,这就是解决它的方法...正如 Mikematic 在这里回答的那样 https://stackoverflow.com/a/56536805/13223528

This has nothing to do with the Tomcat configuration. It is the SELinux on RHEL and CentOS boxes preventing the read write permissions on folders not associated with default tomcat installation. To fix this, install the SELinux management tool and set permissive for tomcat_t SELinux type.

yum install selinux-policy-devel

semanage permissive -a tomcat_t

关于java - Tomcat 7 和 CentOS 7 中的远程调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62054521/

相关文章:

java - 不使用 goto 命令跳转到先前的代码

java - Tomcat v8.0 服务器启动失败

python - 使用 python centos-7 安装 theano

mysql - 在 CentOS 7 (x64) 中通过 bash shell 脚本安装 MySQL Community Server 5.7

java - Autowiring 在 Apache Shiro 自定义 Realm 类中不起作用

java - 我可以在没有 - 标志的情况下使用 Commons CLI 命令行吗?

java - 以毫秒为单位的时间表示标准的名称

java - 正在解析: SunCertPathBuilderException: unable to find valid certification path to requested target

java - 在 Tomcat 服务器上加载静态文件

centos - RMySQL错误 'configure'存在但不可执行