You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Tomcat(8081端口)下通过Mbeans/JMX启停Web应用报错的解决办法

Fixing the InstanceNotFoundException When Managing Tomcat Web App via JMX

Hey there, let's get this sorted out for you. The javax.management.InstanceNotFoundException error you're hitting is mainly due to two mismatches between your code and your Tomcat setup (the non-default 8081 port) and how Tomcat registers web app MBeans. Here's exactly what you need to modify:

1. Update the JMX Connection Address (If Applicable)

If your code uses an HTTP-based JMX proxy (like accessing Tomcat's manager JMX endpoint) or a remote JMX connection, swap the default 8080 port with your actual Tomcat port 8081:

  • For HTTP proxy: Change the endpoint URL from http://localhost:8080/manager/jmxproxy to http://localhost:8081/manager/jmxproxy
  • For remote JMX connection: If you’ve configured a dedicated JMX remote port in catalina.sh/catalina.bat (via com.sun.management.jmxremote.port), ensure you’re using that correct port (note: this is usually different from your HTTP port 8081)

2. Fix the MBean ObjectName

This is the core issue behind your exception. Tomcat registers web app MBeans with a name attribute that includes the full URL of the app—since your Tomcat runs on 8081, your original ObjectName misses this port number.

Your original ObjectName:

Catalina:J2EEServer=none,name=//localhost/adapaconsole,J2EEApplication=none,j2eeType=WebModule

Replace it with this corrected version:

Catalina:J2EEServer=none,name=//localhost:8081/adapaconsole,J2EEApplication=none,j2eeType=WebModule

The key change is adding :8081 after localhost in the name property—this matches how Tomcat registers your adapaconsole app’s MBean, so your code will finally locate the correct instance.

3. Verify User Permissions

Just to rule out extra hurdles, make sure your Tomcat user (configured in tomcat-users.xml) has the manager-jmx role assigned. Without this, you might hit permission errors even after fixing the above:

<user username="your-jmx-user" password="your-password" roles="manager-jmx"/>

After making these adjustments, your code should successfully locate the adapaconsole app’s MBean and let you start/stop/reload it without restarting Tomcat.

内容的提问来源于stack exchange,提问作者Anuj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:42:16