When to use Tomcat CATALINA_OPTS instead of JAVA_OPTS - See more at: http://www.tikalk.com/java/when
2016-02-15 10:36
776 查看
转自:http://www.tikalk.com/java/when-use-tomcat-catalinaopts-instead-javaopts/
We have an environment with the follwing elements:
Apache Tomcat Version 6.0.29
JMX technology
Web application
Every time we stop the tomcat server using the standrd shutdown.sh script it was failed, the tomcat process remains alive and the following exception was thrown:
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7004; nested exception is: java.net.BindException: Address already in use
We know that 7004 is our JMX remote port, but it was not clear why the tomcat shutdown requires to bind this port.
After some research we found out that when tomcat starts, port 7004 (in this example) is bound. For shutdown, another jvm is launched and gets the same jmx parameters. Therefore, it tries to bind to port 7004, too, fails and shuts the jvm down. The shutdown
procedure and thus tomcat is still running.
The problem is actually wider because each JAVA_OPTS property is also being used also when shutting down, and in most cases this is not the behavior we might expect. Think we would like to extend the VM memory, we probably don't want the shutdown to start a
second VM with that memory size.
Tomcat community has been released a fix for this issue from tomcat 5.5.21 onwards and it called CATALINA_OPTS.
All we need is to undersatnd how to use it properly. Properties that will be set to CATALINA_OPTS will be apply to start and rub but not stop, JAVA_OPTS will apply to all three.
For example in our case we need to set the JMX remote port to CATALINA_OPTS and not to JAVA_OPTS:
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=7004"
After using this method the tomcat shutdown process is working smoothly.
- See more at: http://www.tikalk.com/java/when-use-tomcat-catalinaopts-instead-javaopts/#sthash.vLQccRcM.dpuf
We have an environment with the follwing elements:
Apache Tomcat Version 6.0.29
JMX technology
Web application
Every time we stop the tomcat server using the standrd shutdown.sh script it was failed, the tomcat process remains alive and the following exception was thrown:
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7004; nested exception is: java.net.BindException: Address already in use
We know that 7004 is our JMX remote port, but it was not clear why the tomcat shutdown requires to bind this port.
After some research we found out that when tomcat starts, port 7004 (in this example) is bound. For shutdown, another jvm is launched and gets the same jmx parameters. Therefore, it tries to bind to port 7004, too, fails and shuts the jvm down. The shutdown
procedure and thus tomcat is still running.
The problem is actually wider because each JAVA_OPTS property is also being used also when shutting down, and in most cases this is not the behavior we might expect. Think we would like to extend the VM memory, we probably don't want the shutdown to start a
second VM with that memory size.
Tomcat community has been released a fix for this issue from tomcat 5.5.21 onwards and it called CATALINA_OPTS.
All we need is to undersatnd how to use it properly. Properties that will be set to CATALINA_OPTS will be apply to start and rub but not stop, JAVA_OPTS will apply to all three.
For example in our case we need to set the JMX remote port to CATALINA_OPTS and not to JAVA_OPTS:
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=7004"
After using this method the tomcat shutdown process is working smoothly.
- See more at: http://www.tikalk.com/java/when-use-tomcat-catalinaopts-instead-javaopts/#sthash.vLQccRcM.dpuf
相关文章推荐
- C# socket nat 映射 网络 代理 转发
- Poj 3057 未AC http://poj.org/showsource?solution_id=15175171
- 远程调用之RMI、Hessian、Burlap、Httpinvoker、WebService的比较
- 数据库,界面,多线程,网络通信
- 通过java发送http请求
- ImageLoader加载网络图片初始化类
- 程序包org.apache.http.client不存在
- 用Telnet发送HTTP请求
- Linux 永久配置网络(重启不还原)
- 基于TcpListener的web服务器
- 【BZOJ 1834】 [ZJOI2010]network 网络扩容
- 他们是如何利用人们的好奇心赚钱的?
- HTTP Session和Cookie工作原理
- HTTP 小议
- HttpSession 那些事
- iOS开发之网络编程--使用NSURLConnection实现大文件下载
- HTTP与HTTPS的区别
- Angular 学习系列 - - $http请求服务
- 厦门巨游网络科技有限公司(HOTPOWER)承接游戏UI外包
- HTTP状态码