When to use Tomcat CATALINA_OPTS instead of JAVA_OPTS - See more at: http://www.tikalk.com/java/when
来源:互联网 发布:php初学者开发工具 编辑:程序博客网 时间:2024/06/05 14:59
转自: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- When to use Tomcat CATALINA_OPTS instead of JAVA_OPTS - See more at: http://www.tikalk.com/java/when
- When to Use Delegates Instead of Interfaces
- When to Use Delegates Instead of Interfaces (C# Programming Guide)
- How to get spring application context object reference? - See more at: http://www.java2novice.com/sp
- 干活来袭:Effective Concurrency: Know When to Use an Active Object Instead of a Mutex
- when to use Java Beans
- How to Programmatically Add/Delete Custom Options in Magento? - See more at: http://apptha.com/blog/
- When to use DMU?
- When to use AtomicReference?
- Wireshark – No interfaces to capture on using Ubuntu 12.04 - See more at: http://www.networkingnut.n
- How to change the price range in layered navigation in Magento? - See more at: http://www.expertweba
- When would someone use Apache Tez instead of Apache Spark, or vice versa?
- When to use assert() and when to use try catch?
- When to use Class.isInstance() & when to use instanceof operator
- msdn:when to use udp
- When to use virtual destructor?
- Spring AOP Advices - Before advice example - xml based configuration - See more at: http://www.java2
- When to use comparable and comparator interfaces in java
- Lua学习笔记-迭代器和泛型for
- codeforces 623d birthday
- 这40项IT技能都能帮你年薪超过12万美元
- XP系统中安装postgresql,出现Problem running post-install step.解决
- COM组件的初始化
- When to use Tomcat CATALINA_OPTS instead of JAVA_OPTS - See more at: http://www.tikalk.com/java/when
- NSNetService
- final和finally,finalize的区别
- response.setContentType()的作用及参数
- C++ Vector 与STL Iterator的使用
- 图书馆位置管理项目之一:环境搭建(java eclipse tomcat mysql)
- 删除list中符合条件的内容
- js中数组(Array)重排序方法深析
- GCD基本概念和Dispatch Queue