首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基本JMX应用

基本JMX应用
EN

Stack Overflow用户
提问于 2012-04-24 05:36:02
回答 1查看 4K关注 0票数 1

我对JMX很陌生,我正在尝试创建一个简单的示例。我正在创建基本的JMX应用程序。我有Server.java,它执行以下操作:

代码语言:javascript
复制
JMXServiceURL url = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnectorServer cs =
JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);

// Start the RMI connector server
echo("\nStart the RMI connector server");
cs.start();

并在cs.start()上获取以下错误消息。

代码语言:javascript
复制
     java.io.IOException: Cannot bind to URL [rmi://localhost:9999/server]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 
    java.net.ConnectException: Connection refused: connect]
    at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)
    at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417)
    at Server.main(Server.java:93)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 
    java.net.ConnectException: Connection refused: connect]
    at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:126)
    at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:208)
    at javax.naming.InitialContext.bind(InitialContext.java:400)
    at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:625)
    at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:412)

在我的glassfish服务器中,我添加了以下属性:

代码语言:javascript
复制
-Dcom.sun.management.jmxremote.ssl.need.client.auth=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=9999

请告诉我少了什么。

编辑:

在使用RMI服务器执行时也是如此。

在RMI服务器上的-Dcom.sun.management.jmxremote.port=9999'命令,我得到以下错误:C:\Program Files\Java\jdk1.6.0_17\bin>java -Dcom.sun.management.jmxremote.port=9999 Error: Password file not found: C:\Program Files\Java\jdk1.6.0_17\jre\lib\management\jmxremote.password

EN

回答 1

Stack Overflow用户

发布于 2013-02-01 11:05:09

参考http://docs.oracle.com/javase/7/docs/technotes/guides/jmx/tutorial/connectors.html#wp1056865的内部内容教如何运行基本的JMX应用程序,

编译Java类。

$ javac *.java

在本地主机的端口9999上启动RMI注册表。服务器将使用RMI注册表注册RMI连接器存根。

$ rmiregistry 9999 &

启动Server类。

$ java -classpath。服务器

在另一个终端窗口中启动客户端类。

$ java -classpath。客户端

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10292256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档