- 浏览: 2105561 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
无心流泪wan:
private static final Log log = ...
log4j Category.callAppenders Block -
yjxa901:
博主好: http://www.java.net/down ...
jdk debug -
aptech406328627:
大神,请接收我的膜拜吧,纠结了两天的问题,就这么让你给解决了 ...
java.lang.reflect.MalformedParameterizedTypeException -
xukunddp:
谢谢1楼,我也遇到,搞定了
java.lang.reflect.MalformedParameterizedTypeException -
di1984HIT:
学习了!!!!
jvmstat hsperfdata java.io.tmpdir
转载自:http://marxsoftware.blogspot.com/2008/06/remote-jmx-exceptions.html(需要fanqiang)
Perhaps the most difficult aspect of getting a freshly written JSR-160
(Remote JMX
) compliant
application working is ensuring a proper JMXServiceURL
.
In this blog entry, I cover some of the most common JMXServiceURL
-related
exceptions one may run into when developing the client and server portions of a
management and monitoring system using Remote JMX.
The JMX
1.4 Specification
combines the original JMX specification with the Remote
JMX specification in a single
document
(the JMX Remote API Specification is part III of this
document
). This third part covers the required RMI
connector
as well as the optional JMXMP connector. In this blog entry, I'll be focusing on
using the RMI connector with Java SE
6
HotSpot
platform
MBean server
. Instead of using JConsole
as a client, I'll use a simple custom client to illustrate some of the
exceptions one may encounter when writing one's own client.
I am using
essentially the same code in this blog for examples that I previously used in
the previous blog entry Remote
JMX: With and Without Spring and Proxies
. I will not reproduce the code
here, but it is sufficient to know that the JMX Connector server code generally
establishes its JMXServiceURL
as service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
. Note
that the protocol is RMI, the host is localhost, the port is 1099, and the URL
string is "jmxrmi". Because the JMX client needs to use the same JMXServiceURL
as provided by the server, I appreciate it when third-party JMX servers provide
this to me. For example, both GlassFish
and the JMX Web Services
Connector
Reference
Implementation
sample
provide their JMXServiceURL
to the console when they are
executed.
When the JMXServiceURL
is known, it is relatively
straightforward to write a client. The most significant lines of code for doing
this are extracted from the code in the previously referenced blog and displayed
next:
final String objectNameStr = "dustin:type=status,name=remoteJMX"; final String jmxRmiStr = "service:jmx:rmi://localhost/jndi/rmi://localhost:1099/jmxrmi"; try { final ObjectName objectName = new ObjectName(objectNameStr); final JMXServiceURL jmxUrl = new JMXServiceURL(jmxRmiStr); final JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl); final MBeanServerConnection mbsc = jmxConnector.getMBeanServerConnection();
As
the code listing above demonstrates, it is fairly easy (and mostly boilerplate)
to connect clients to a JMX Connector Server with a well-known
JMXServiceURL
. However, it is not uncommon for new JMX developers
to struggle to get the JMXServiceURL
appropriately set. In the
remainder of this blog entry, I now look at some of the most common
JMXServiceURL
-related exceptions one may run
into.
ERROR: IOException trying to
connect to JMX Connector Server
: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException
[Root
exception is java.rmi.ConnectException
:
Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
A
possible cause of this exception includes no JMX Connector Server running on the
specified host and port combination.
Also, ensure that an RMI registry
has been started at the specified port.
ERROR: IOException
trying to connect to JMX Connector Server:
Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmx-
rmi
This NameNotFoundException
was a result of
inadvertently mistyping the client's String URL portion (jmx-rmi
specified by the client rather than jmxrmi
without the hyphen).
This is different from the above error because a JMX Connector Server is at the
specified host and port, but with a different String portion. Because multiple
JMX Connector Servers can use the same host/port combination as long as they
have unique String portions of their URLs, it is not surprising that no
assumptions can be made about what String was
intended.
Exception in thread "main" java.lang.ClassCastException
: com.sun.jndi.rmi.registry.RegistryContext cannot be cast to
javax.management.remote.rmi.RMIServer
The previous
exception demonstrated the result of attempting to access a JMX Connector Server
from a client with the correct host/port comibination, but with an incorrect
String URL portion. This ClassCastException
is the result of not
specifying any String URL portion at all in the JMXServiceURL
. In
other words, the jmxrmi
portion was left off the end of the
client's
JMXServiceURL
.
java.io.IOException:
Cannot bind to URL
[rmi://localhost:1099/jmxrmi]
: javax.naming.NameAlreadyBoundException
: jmxrmi
[Root exception is java.rmi.AlreadyBoundException: jmxrmi
]
Until
now, all of the previously covered exceptions resulted from a JMX Client using a
mistyped or otherwise incorrect JMXServiceURL
that did not match
that used by the JMX Connector Server. This exception, however, is a JMX
Connector Server exception that results from two different applications trying
to use the same JMXServiceURL on the same host/port with the same URL
String.
ERROR: Problem with
JMXServiceURL
based on rmi:///jndi/rmi://localhost:1099/jmxrmi: Service URL must start with
service:jmx:
This error message is particularly
descriptive and occurs when the JMXServiceURL
does not begin with
the specification-required service:jmx:
portion. See Section 13.8
("Connector Server Addresses") for additional details on all
JMXServiceURL
s beginning with this
portion.
ERROR: Problem with
JMXServiceURL
based on service:jmx::
///jndi/rmi://localhost:1099/jmxrmi: Missing or invalid protocol name:
""
As the error message indicates, the protocol is
missing from the JMXServiceURL
, which should be
service:jmx:rmi
:///jndi/rmi://localhost:1099/jmxrmi
, but
the portion in red
was
omitted.
ERROR: Problem with
JMXServiceURL
based on service:jmx:nothing
:///jndi/rmi://localhost:1099/jmxrmi: Unsupported protocol: nothing
Whereas
the previous error message indicated a missing protocol designation, this error
indicates an erroneous protocol specification. In this particular case, the
incorrect JMXServiceURL
used was service:jmx:nothing
:///jndi/rmi://localhost:1099/jmxrmi
where the "nothing" in red
should have been
"rmi".
ERROR: IOException
trying to connect to JMX Connector Server: Failed to retrieve RMIServer stub:
javax.naming.NoInitialContextException: Need to specify
class name in environment or system property, or as an applet parameter, or in
an application resource file:
java.naming.factory.initial
This error message is
displayed for the case where the second protocol listing in the
JMXServiceURL
is either omitted or has an incorrect value. In other
words, if the highlighted
portion of the correct
JMXServiceURL
(service:jmx:rmi:///jndi/rmi
://localhost:1099/jmxrmi
)was omitted
entirely or had something unexpected like "nothing," this error message would
occur.
Other Remote JMX Exceptions/Errors
Considerations
There are, of course, several other types of
exceptions one can run into when remotely accessing a JMX Connector Server.
These exceptions, which have not been covered here, are those that are thrown
when the connection is successfully made, but the sought-after MBean cannot be
found or some other problem occurs. The JMX
Best Practices
document outlines recommendations related to MBeans
throwing standard exceptions
and also recommends having MBeans intended for
remote management/monitoring implement interfaces with operations that use the
throws
IOException
clause (more granular for client than available as UndeclaredThrowableException
).
JMX
Exceptions in General
The focus of this blog entry has been on
common exceptions and errors encountered when running a custom JMX Connector
Client with a custom JMX Connector Server. Note that JMX spells out its own
exception hierarchy related to the JMX Agent. Section 6.4 (JMX Exceptions) of
the JMX 1.4 Specification is devoted to these JMX exceptions. The section talks
about the JMException
,
which is the main class and parent of all descendant exception classes
(exception runtime exceptions) thrown by a JMX agent implementation. The JMX
runtime exceptions are represented by JMRuntimeException
and its descendant exceptions.
发表评论
-
groovy shell 安全
2017-01-18 11:29 1202groovy 可以动态执行代码,但是我们也想他在一定的沙箱中 ... -
eclipse 插件
2016-11-17 12:00 608eclipse remote editor https: ... -
java method signature
2013-08-12 21:07 2717case 'B': _type = T_BYT ... -
eclipse显示GC的按钮
2013-06-18 19:32 4333同事说idea的一个比较亮的功能是可以手动去GC,然后机器 ... -
好用的maven插件收集
2013-02-22 10:40 13481:Maven Shade Plugin(把所有jar打到一 ... -
查看JVM Flags
2013-01-09 14:22 1333-XX:+PrintFlagsFinal Jav ... -
开源的好用JVM问题排查工具
2013-01-08 09:45 1859TProfiler https://github.com/ ... -
java ocr
2013-01-04 13:06 3018java OCR相关的资料记录 Clara OC ... -
eclipse ast
2012-12-23 22:36 1011Eclipse JDT - Abstract Syntax ... -
正则生成器
2012-12-23 22:24 976能够依据普通文本给出可能的正则组合 http://ww ... -
Kilim
2012-12-14 23:40 1109Java 开发 2.0: Kilim 简介 h ... -
IO Design Patterns Reactor VS Proactor
2012-11-13 01:34 15081:两种高性能I/O设计模式(Reactor/Proactor ... -
antlr
2012-11-13 00:36 12181:使用 Antlr 开发领域语言 http://www.i ... -
java singalException
2012-11-12 21:39 981之前看到毕大师一封关于异常多造成的cpu us很高的分析邮件, ... -
log4j Category.callAppenders Block
2012-11-06 17:01 10105经常在高并发下就遇到log4j用错引起的线程block住的问题 ... -
Troubleshooting JDK
2012-10-26 14:13 1522收集整理下JDK自带的关于 Troubleshooting 的 ... -
JavaOne 2011 Content Catalog
2012-10-14 17:12 1168上一篇讲javaone 2012,这次找了下2011的资料。 ... -
JavaOne 2012 Content Catalog
2012-10-13 16:07 1308转载自:http://marxsoftware.blogspo ... -
Memory usage of Java
2012-10-01 17:30 1217用JDK自带的api计算size,每次都会有个多余的12,看了 ... -
GC roots
2012-10-01 17:07 18501:GC roots http://www.yourkit. ...
相关推荐
catalina jmx remote jmx 监控 tomcat 资源
tomcat-catalina-jmx-remote-9.0.5 tomcat-catalina-jmx-remote-9.0.5.jar
`catalina-jmx-remote.rar`这个压缩包文件,显然与通过JMX远程访问Catalina相关,让我们深入探讨一下这个主题。 首先,理解JMX的原理和作用是至关重要的。JMX允许开发者创建和注册管理对象(MBeans),这些对象代表...
在本场景中,我们将介绍如何使用RMI(Remote Method Invocation)连接方式来实现JMX框架的各层级的连接。 MBean是JMX框架的基本组件,用于提供管理信息和功能。MBean可以是任何Java对象,只要它实现了相关的接口。...
用于windows通过VisualVM远程监控linux下的tomcat使用情况时所需要的jar包。可监控CPU、内存、类和线程。
2. **jmx_remote-1_0_1_03-ri.zip**:此文件是JMX Remote API的一个实现,版本为1.0.1_03。JMX Remote API扩展了基本的JMX,使得管理操作可以跨越网络进行,允许远程监控和管理Java应用程序。这个版本可能包含了更新...
zabbix配置tomcat所需要的jmx的jar包,这里对应tomcat的8.0.36版本
这个"jmx-1.2.1(jmxri+jmxtools) jar"包含了JMX的两个核心组件:JMX Remote Interface (jmxri) 和 JMX Tools。 1. **JMX Remote Interface (jmxri)**: JMX Remote Interface 是JMX框架的一部分,它允许远程访问和...
1. **远程JMX连接**:Java默认使用Remote Method Invocation (RMI) 协议来实现远程JMX连接。通过设置`-Dcom.sun.management.jmxremote.rmi.port`和`-Dcom.sun.management.jmxremote.port`等参数,可以启用RMI服务,...
此jar包为zabbix监控tomcat时用到的库文件包,请结合zabbix官网中操作明细来实施操作
- `jmxri-1.2.1.jar`:JMX Remote Lifecycle API,实现了JMX的远程访问功能,使得我们可以远程监控和管理应用。 - `jmxtools-1.2.1.jar`:包含了一些JMX工具,如JConsole,用于图形化地查看和管理Java应用程序的...