Weblogic MBean Server远程JMX(T3协议)连接异常求助
Weblogic JMX连接Domain Runtime MBean Server阻塞问题解决
问题核心
你尝试通过t3协议连接Weblogic AdminServer的Domain Runtime MBean Server以实现域级监控,但连接过程卡住(仅打印MAKING JMX CONNECTION...无后续输出);使用通用RMI JMX连接虽能成功,但无法获取域内服务器会话、连接等所需的MBeans(该连接指向平台MBean Server,而非Weblogic专属的Domain Runtime MBean Server)。
解决步骤
1. 修正AdminServer启动参数
当前启动参数仅配置了通用JMX RMI远程支持,需添加Weblogic专属JMX远程配置:
# 保留原有参数,新增以下两行 -Dweblogic.management.remote.enabled=true -Dweblogic.management.server=http://<ADMIN_SERVER_IP>:<ADMIN_CONSOLE_PORT>
weblogic.management.remote.enabled=true:开启Weblogic远程JMX管理功能weblogic.management.server:指定AdminServer的访问地址(远程连接必须配置)
2. 补充客户端依赖包
仅添加wlthint3client.jar不足以支持Weblogic JMX连接,需从WLS安装目录wlserver/server/lib下添加以下JAR到类路径:
weblogic.jarwljmxclient.jarwlclient.jar
3. 调整JMX连接代码
修正JMXServiceURL配置
注意:连接用的端口是AdminServer的T3通信端口(默认7001),而非你配置的9001(通用JMX RMI端口):
String protocol = "t3"; String hostname = "<ADMIN_SERVER_IP>"; int port = 7001; // 替换为你的AdminServer T3端口 String jndiroot = "/jndi/"; String mBeanServer = "weblogic.management.mbeanservers.domainruntime"; JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port, jndiroot + mBeanServer);
完善连接属性(添加超时与兼容配置)
Hashtable<String, String> hashtable = new Hashtable<>(); hashtable.put(Context.SECURITY_PRINCIPAL, username); hashtable.put(Context.SECURITY_CREDENTIALS, password); hashtable.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote"); // 添加超时配置,避免无限阻塞 hashtable.put("weblogic.jmx.connect.timeout", "30000"); hashtable.put("weblogic.jmx.read.timeout", "30000"); // 若服务器开启SSL,添加忽略主机名验证(可选) hashtable.put("weblogic.security.SSL.ignoreHostnameVerification", "true");
4. 验证连接与MBean获取
连接成功后,可通过以下代码验证是否能获取域内服务器监控数据:
MBeanServerConnection connection = getMBeanServerConnection(); // 获取DomainRuntimeServiceMBean ObjectName domainRuntimeService = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"); // 获取所有服务器运行时实例 ObjectName[] serverRuntimes = (ObjectName[]) connection.getAttribute(domainRuntimeService, "ServerRuntimes"); for (ObjectName serverRuntime : serverRuntimes) { String serverName = (String) connection.getAttribute(serverRuntime, "Name"); System.out.println("服务器:" + serverName); // 获取Web应用活跃会话数示例 ObjectName webAppRuntime = new ObjectName(serverRuntime.getCanonicalName() + ",Type=WebAppRuntime,Name=你的Web应用名称"); Integer activeSessions = (Integer) connection.getAttribute(webAppRuntime, "ActiveSessionsCurrentCount"); System.out.println("当前活跃会话数:" + activeSessions); }
5. 额外排查点
- 确认AdminServer的T3端口可通过telnet访问
- 保证客户端WLS版本(14.1.1)与服务器端版本完全一致,版本不兼容会导致连接失败
- 检查AdminServer日志(
servers/AdminServer/logs/AdminServer.log),查找连接失败的具体报错信息
内容的提问来源于stack exchange,提问作者Filip Pitak
相关产品推荐
相关产品推荐

