Apache Tomcat Cataline 文件更改未反映!
我在 windows xp prefossional SP3 上使用 apache-tomcat-6.0.18 。
我的要求是在 Tomcat Manager => 中显示附加信息(如组织名称)服务器状态=>在 JVM 和 http- 标头之间。我已经修改了 catalina.jar 源中的文件 "org.apache.catalina.manager.StatusTransformer::writeConnectorState
并向其中添加了简单文本。示例代码
public static void writeConnectorState(PrintWriter writer, ObjectName tpName, String name, MBeanServer mBeanServer, Vector globalRequestProcessors, Vector requestProcessors, int mode)throws Exception{
if (mode == 0) {
// START - Added New Code to display org name
writer.print("<h1>");
writer.print("XYZ Organization.");
writer.print("</h1>");
// END - Added New Code to display org name
writer.print("<h1>");
writer.print(name);
writer.print("</h1>");
writer.print("<p>");
writer.print(" Max threads: ");
writer.print(mBeanServer.getAttribute(tpName, "maxThreads"));
writer.print(" Current thread count: ");
writer.print(mBeanServer.getAttribute(tpName, "currentThreadCount"));
writer.print(" Current thread busy: ");
writer.print(mBeanServer.getAttribute(tpName, "currentThreadsBusy"));
...........
...........
}else{
.........
}// end if-else }// method end
再次使用修改后的代码创建了catalina.jar。并替换为 catalina_home/bin
中的现有 jar。重新启动了tomcat,但没有任何结果。
即使我从 catalina_home/bin
中删除 catalina.jar 并启动 tomcat,它仍然可以工作!
我什至在重新启动系统后尝试过,但我的更改没有反映。
请帮我解决以下问题
- 我是否修改了错误的文件?
- 没有catalina.jar的情况下tomcat如何运行?
- 如何体现变化?即还有其他方式吗?
I am using apache-tomcat-6.0.18 on windows xp prefossional SP3.
My requirement is to show additional information ( like Organization Name) in the Tomcat Manager => Server Status => in between the JVM and http- Header. I have modified the file "org.apache.catalina.manager.StatusTransformer::writeConnectorState<method name>"
from catalina.jar source and added simple text to it. Sample code is
public static void writeConnectorState(PrintWriter writer, ObjectName tpName, String name, MBeanServer mBeanServer, Vector globalRequestProcessors, Vector requestProcessors, int mode)throws Exception{
if (mode == 0) {
// START - Added New Code to display org name
writer.print("<h1>");
writer.print("XYZ Organization.");
writer.print("</h1>");
// END - Added New Code to display org name
writer.print("<h1>");
writer.print(name);
writer.print("</h1>");
writer.print("<p>");
writer.print(" Max threads: ");
writer.print(mBeanServer.getAttribute(tpName, "maxThreads"));
writer.print(" Current thread count: ");
writer.print(mBeanServer.getAttribute(tpName, "currentThreadCount"));
writer.print(" Current thread busy: ");
writer.print(mBeanServer.getAttribute(tpName, "currentThreadsBusy"));
...........
...........
}else{
.........
}// end if-else }// method end
Again created catalina.jar with modified code. and replaced with the existing jar from catalina_home/bin
. Restarted the tomcat but nothing coming out of it.
Even if i remove catalina.jar from catalina_home/bin
and starts the tomcat, its working!!!!
I tried even after restarting the system but my changes are not reflecting.
Please help me out for the following queries
- Am i modifying the wrong file?
- How tomcat is running without catalina.jar?
- How to reflect the changes? i.e. Any other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对此不是 100% 确定,但我认为您应该将修改后的 catalina.jar 放在
catalina_home/lib
中,因为我相信这是 Web 应用程序加载其共享库的位置(Tomcat Manager 只是另一个应用程序)在catalina_home/webapps/
下)。编辑:我检查了我们的一台服务器,
catalina_home/bin
下没有catalina.jar
,只有catalina_home/lib
下。Not 100% sure on this, but I think you should place the modified catalina.jar in
catalina_home/lib
, as I believe that's where the web-applications load their shared libraries (Tomcat Manager is just another app undercatalina_home/webapps/
).Edit: I checked one of our servers, there's no
catalina.jar
undercatalina_home/bin
, only undercatalina_home/lib
.