linux tomcat 报错,Linux下tomcat启动报错:port already in use

导致该问题的原因很多,标题说明不了具体问题。

在此仅说下我的操作,遇到的问题及其解决方法,希望能起到抛砖引玉的作用。

启动tomcat,报错如下:

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7800; nested exception is:

java.net.BindException: Address already in use

检查了${TOMCAT_HOME}/conf/server.xml,context.xml,web.xml等配置文件,未发现配置7800端口的地方。

引用内容如下:

Port already in use error when trying to shutdown Apache Tomcat with JMX monitoring enabled

So you tried to use JMX to monitor your Tomcat instance. You might have done so with the following lines in catalina.sh:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8085"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

Everything started up nicely, and you were able to monitor. YAY!

But when you ran the shutdown script:

user@host:/apache-tomcat-6.0.26$ bin/shutdown.sh

Using CATALINA_BASE: /apache-tomcat-6.0.26

Using CATALINA_HOME: /apache-tomcat-6.0.26

Using CATALINA_TMPDIR: /apache-tomcat-6.0.26/temp

Using JRE_HOME: /usr/lib/jvm/java-6-sun

Using CLASSPATH: /apache-tomcat-6.0.26/bin/bootstrap.jar

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 8085; nested exception is:

java.net.BindException: Address already in use

Only a kill -9 would bring down tomcat. Uh oh!

Setting these properties in JAVA_OPTS tries to start a jmx server when you start tomcat AND when you shutdown tomcat. Hence the port already in use exception. You need to set these properties for CATALINA_OPTS instead of JAVA_OPTS. This will only run when you start tomcat.

CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999"

CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

于是从 ${TOMCAT_HOME}/bin/catalina.sh 启动文件中找到了答案。

JAVA_OPTS="-server -Xms2048m -Xmx2048m -XX:PermSize=512m -XX:MaxPermSize=512m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.pwd.file=/opt/app/appcode/jmxremote.password -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=7803"

分析了一下,因为tomcat不是由我配置,本人仅维护而已,从而不能全部掌握安装人员的配置精髓。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值