解决tomcat shutdown时的地址被占用问题

总是在tomcat的启动脚本catalina.sh的一开始加上dubug参数,以供远程debug,原参数如下

JAVA_OPTS='-XX:PermSize=728m -XX:MaxPermSize=728m -Xms1024m -Xmx1024m -DNode=DLOG4J 
-DProductMode=false -Dfile.encoding=utf-8 
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n'

 

但是这样做后,再运行tomcat的shutdown.sh脚本会报错:

ERROR: transport error 202: bind failed: Address already in use ["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initializedFATAL ERROR in native method: JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNAL(113)

以前总是懒得弄,直接killall -9 java 了事,但是现在同一台机器上装了很多服务,不能直接 killall了,用ps -ef | grep java去查又比较麻烦

所以查了一下google,得到结果

You are trying to debug tomcat on startup, so it binds to port 5005 when the jvm starts.

When you run catalina.sh stop, it starts up another jvm which also tries to bind to port 5005.

You need to move the debug args to the run and start arguments (in catalina.sh) of tomcat, putting them straight into the JAVA_OPTS is the cause of the issue you're having.

最后有一个非常简单的解决方法:

CATALINA_OPTS 参数替代 JAVA_OPTS 参数 

把dubug参数换成:

CATALINA_OPTS='-XX:PermSize=728m -XX:MaxPermSize=728m -Xms1024m -Xmx1024m -DNode=DLOG4J  
-DProductMode=false  -Dfile.encoding=utf-8 
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n'


转载于:https://my.oschina.net/u/1770666/blog/370620

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值