1

私はJMXが初めてで、簡単な例を作成しようとしています。基本的な JMX アプリケーションを作成しています。次のことを行う Server.java があります。

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() で次のエラー メッセージが表示されます。

     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)

私のグラスフィッシュサーバーでは、次のプロパティを追加しました:

-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サーバーを使用して実行中..

-Dcom.sun.management.jmxremote.port=9999'RMI サーバーでコマンドを実行すると、次のエラーが発生します。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

4

1 に答える 1

2

http://docs.oracle.com/javase/7/docs/technotes/guides/jmx/tutorial/connectors.html#wp1056865を参照 してください


Java クラスをコンパイルします。
$ javac *.java

ローカル ホストのポート 9999 で RMI レジストリを開始します。RMI レジストリは、RMI コネクタ スタブを登録するためにサーバーによって使用されます。
$ rmiregistry 9999 &

サーバークラスを開始します。
$ java -クラスパス . サーバ

別のターミナル ウィンドウで Client クラスを開始します。
$ java -クラスパス . クライアント

于 2013-02-01T11:05:09.877 に答える