在Tomcat 7和CentOS 7中进行远程调试 [英] Remote debugging in Tomcat 7 and CentOS 7

查看:204
本文介绍了在Tomcat 7和CentOS 7中进行远程调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  5月27日23:02:58 lab5服务器:错误:传输错误202:绑定失败:权限被拒绝
5月27日23: 02:58 lab5服务器:错误:JDWP传输dt_socket初始化失败,TRANSPORT_INIT(510)
5月27日23:02:58 lab5服务器:JDWP退出错误AGENT_ERROR_TRANSPORT_INIT(197):没有初始化传输[debugInit.c:750 ]
5月27日23:02:58 lab5 systemd:tomcat.service:主进程已退出,代码=已退出,状态= 2 / INVALIDARGUMENT
5月27日23:02:58 lab5 systemd:单元tomcat.service进入失败状态。
May 27 23:02:58 lab5 systemd:tomcat.service失败。

我尝试了多种方法。

  -Xdebug -Xrunjdwp:transport = dt_socket,地址= myec2privateip:2345,服务器= y,暂挂= n \ 
-agentlib:jdwp = transport = dt_socket,address = myec2privateip :2345,suspend = y,服务器= n \
-agentlib:jdwp = transport = dt_socket,address = myec2privateip:2345,suspend = y,server = y \
-agentlib:jdwp = transport = dt_socket,地址= myec2privateip:2345,暂挂= n,服务器= y \
-agentlib:jdwp = transport = dt_socket,地址= myec2privateip:2345,暂挂= n,服务器= n \
-Xdebug -Xrunjdwp:服务器= y,运输= dt_socket,地址= 4000,暂挂= n
-Xdebug -Xrunjdwp:服务器= y,运输= dt_socket,地址= myec2privateip:2000,暂挂= n
#JPDA_ADDRESS = myec2privateip:32702
#JPDA_OPTS =-agentlib:jdwp = transport = dt_socket,server = y,suspend = n,address = 32702
-agentlib:jdwp = transport = dt_socket,服务器= y,地址= 8000 \
-agentlib:jdwp = transport = dt_socket,服务器= y,地址= *:8000,暂停= n \
JAVA_TOOL_OPTIONS =-年龄ntlib:jdwp = transport = dt_socket,地址= 8000,服务器= y,暂挂= n
agentlib:jdwp = transport = dt_socket,地址= localhost:39621,suspend = n,服务器= y -Xdebug
-Xdebug -agentlib:jdwp = transport = dt_socket,address = 2345,server = y,suspend = n -Djava.security.debug = all

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



Tomcat在具有以下CentOS AMI的AWS EC2实例上 CentOS Linux 7 x86_64 HVM EBS 1602



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



Java版本




  • OpenJDK版本 1.8.0_242

  • OpenJDK运行时环境(内部版本1.8.0_242-b08)

  • OpenJDK 64位服务器VM(内部版本25.242-b08,混合模式)



如果删除已添加的参数,则Tomcat运行良好。



为什么会发生此错误,为什么?



我主要在 / etc / sysconfig / tomcat中设置它吗?



code>在 JAVA_OPTS 下,但是尝试了其他位置。

解决方案

对于其他在Centos7上执行此操作并遇到相同问题的人大约有100万件事,这是解决问题的事情... Mikematic在这里 https://stackoverflow.com/a/56536805回答/ 13223528


这与Tomcat配置无关。它是RHEL和CentOS机器上的SELinux,阻止了与默认tomcat安装无关的文件夹的读写权限。要解决此问题,请安装SELinux管理工具并为tomcat_t SELinux类型设置许可。

  yum install selinux-policy-devel 

允许的管理-a tomcat_t



I'm trying to setup remote debugging from IntelliJ to a Tomcat, but forget IntelliJ for now because I haven't started with that. I'm trying to set it up on the server initially, I'm trying to setup tomcat so that it can accept those connections but when I add the jdwp flags/arguments, tomcat won't start with the following error.

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.

I've tried multiple ways.

-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

For the ports I've tried above, there's nothing running on them. This is not an issue of connection timing out, it's not an issue of firewalls etc.

The Tomcat is on an AWS EC2 instance with the following CentOS AMI "CentOS Linux 7 x86_64 HVM EBS 1602"

The Tomcat I have installed is from yum, "tomcat-7.0.92-1.el7.noarch"

Java version

  • OpenJDK version "1.8.0_242"
  • OpenJDK Runtime Environment (build 1.8.0_242-b08)
  • OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

The Tomcat is working perfectly fine if I remove the arguments I've been adding.

Why might this error be happening, and why can't I get Tomcat to start with any of these?

I've been setting it mostly in /etc/sysconfig/tomcat under JAVA_OPTS, but have tried other locations.

解决方案

For anyone else doing this on Centos7 and having the same issue, after trying a million things, this is the thing that solved it... as answered by Mikematic here 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

这篇关于在Tomcat 7和CentOS 7中进行远程调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆