为什么可以通过 jmxrmi 端口 1099 访问 Tomcat 服务器 [英] Why Tomcat server is accessible thru jmxrmi port 1099

查看:72
本文介绍了为什么可以通过 jmxrmi 端口 1099 访问 Tomcat 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是,如果我们配置以下属性,可以通过 jmxrmi 访问 tomcat 服务器.端口也可以配置.

My understanding is that tomcat server can be accessed thru jmxrmi if we configure following properties. Port can also be configured.

-Dcom.sun.management.jmxremote.port=30000
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.password.file=xyz
-Dcom.sun.management.jmxremote.access.file=xyz

之后可以通过一些 jmx 工具(如 jconsole 或 jvisualvm 等)连接 tomcat 服务器.但我也注意到同样的 tomcat 服务器也可以连接到默认的 jmxrmi 端口 1099.我还没有在任何地方配置端口 1099.即使我评论除去以上所有属性,我看到在 jvisualvm 上,tomcat 仍然可以连接到端口 1099.

After that tomcat server can be connected thru some jmx tools like jconsole or jvisualvm etc. But I also noticed that same tomcat server can also be connected on default jmxrmi port 1099. I havent configured anywhere port 1099. Even though if I comment out all above properties, I see tomcat still can be connected to on port 1099 on jvisualvm.

请提出建议,可能在默认端口上启用此连接的原因是什么.以及如何禁用此连接?

Please suggest, what might be enabling this connectivity on default port. And how can I disable this connectivity?

类路径中的其他一些第三方库可能正在这样做,但如何确定是哪一个?

Possibly some other third party libraries in classpath might be doing it, but how to figure which one?

推荐答案

JMX 使用两个端口:一个用于 JMX 连接(您已设置为端口 30000),另一个用于 RMI 通信.Java 默认使用 1099 端口,但如果正在使用,则会选择 1099 之后的第一个可用端口.在 Java 8 中,您无法通过系统属性显式设置此端口.

JMX uses two ports: one for the JMX connection (which you have set to port 30000) and another one for RMI communications. Java defaults to port 1099, but if it's in use, it will choose the first port available after 1099. In Java 8, you cannot explicitly set this port via system properties.

对于更高的 Java 版本,您可以使用系统属性 com.sun.management.jmxremote.rmi.port.

For later Java versions, you can use the system property com.sun.management.jmxremote.rmi.port.

Tomcat 有一个解决方法.您可以使用 JmxRemoteLifecycleListener 设置 rmiServerPortPlatform 属性.将其设置为您喜欢的任何端口.

Tomcat has a workaround for this. You can use the JmxRemoteLifecycleListener to set the rmiServerPortPlatform attribute. Set that to whatever port you prefer.

请注意,您不能禁用第二个端口:它是必需的 JMX 才能正常运行.

Note that you cannot disable this second port: it is required for JMX to operate properly.

这篇关于为什么可以通过 jmxrmi 端口 1099 访问 Tomcat 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆