0

MBean を使用して Websphere 7 環境を監視しようとしていますが、多くの問題が発生しています。まず、以下に投稿されたコードを使用すると、次の例外が発生します。

com.ibm.websphere.management.exception.ConnectorException: ポート 2809 でホスト localhost に接続するための RMI コネクターを作成できませんでした

例外を生成するコードは次のとおりです。

import java.util.Properties;

import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;


public class JustAdminClient {
private AdminClient adminClient;

private void initialize() throws Exception {
    try {
        // Initialize the AdminClient.
        Properties adminProps = new Properties();
        adminProps.setProperty("type", AdminClient.CONNECTOR_TYPE_RMI);
        adminProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "false"); 
        adminProps.setProperty(AdminClient.CONNECTOR_HOST, "localhost");
        adminProps.setProperty(AdminClient.CONNECTOR_PORT, "2809");
        adminClient = AdminClientFactory.createAdminClient(adminProps);
    } catch (Exception ex) {
        ex.printStackTrace(System.out);
        throw ex;
    }
}   // end method

/**
 * @param args
 */
public static void main(String[] args) {
    JustAdminClient adClient = new JustAdminClient();
    try {
        adClient.initialize();
    } catch (Exception e) {
        e.printStackTrace();
    }
}   // end main

}   // end class

次に、セキュリティを無効にして WAS スタンドアロンを実行しています。自己署名証明書を構成する必要がありますか?

私のsecurity.xmlは次を示しています:

<security:Security xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
  xmlns:orb.securityprotocol="http://www.ibm.com/websphere/appserver/schemas/5.0/orb.securityprotocol.xmi"
  xmlns:security="http://www.ibm.com/websphere/appserver/schemas/5.0/security.xmi" xmi:id="Security_1"
  useLocalSecurityServer="true" useDomainQualifiedUserNames="false" 
  issuePermissionWarning="true" activeProtocol="BOTH" 
  enforceJava2Security="false" enforceFineGrainedJCASecurity="false"
  appEnabled="true" dynamicallyUpdateSSLConfig="true" 
  allowBasicAuth="true" activeAuthMechanism="LTPA_1"
  activeUserRegistry="LocalOSUserRegistry" enabled="false" cacheTimeout="600"
  defaultSSLSettings="SSLConfig_RXCW510MONNode01_1" adminPreferredAuthMech="RSAToken_1">

リンクごと: http://www-01.ibm.com/support/docview.wss?uid=swg21295051

ポート 2809 には 2 つの方法で接続できます。WSadamin と、以下を含む Java プログラムを使用します。

private void connect(String host,String port) throws Exception
    {
        String jndiPath="/WsnAdminNameService#JMXConnector";

        JMXServiceURL url = new JMXServiceURL("service:jmx:iiop://"+host+"/jndi/corbaname:iiop:"+host+":"+port+jndiPath);
        System.out.println("URL = " + url);
        //JMXServiceURL url = new JMXServiceURL("service:jmx:iiop://192.168.0.175:9100/jndi/JMXConnector");

        Hashtable h = new Hashtable();

        //Specify the user ID and password for the server if security is enabled on server.

        //Establish the JMX connection.
        System.out.println("Before JMXConnector");
        JMXConnector jmxc = JMXConnectorFactory.connect(url, h);

        //Get the MBean server connection instance.
        System.out.println("Before getMBeanServerConnection");
        mbsc = jmxc.getMBeanServerConnection();

        System.out.println("Connected to Application Server");
    }   // end method

何か案は?道に迷い、長いスレッドで申し訳ありませんが、事前に情報を確認することをお勧めします.

4

2 に答える 2

0

次のサンプルコードスニペットと表記法を使用して問題を解決しました。スローされた例外とメッセージ re: msing classes; に特に注意してください。つまり、「作成できませんでした」というメッセージに焦点を当てると、誤解を招く可能性があります

次の jar ファイルが必要です。

  • %WAS_HOME%\runtimes\com.ibm.jaxws.thinclient_7.0.0.jar %WAS_HOME%\plugins\com.ibm.ws.runtime.jar %WAS_HOME%\plugins\deploytool\itp\com.ibm.websphere.v7_7. 0.0.v20080817\wasJars\com.ibm.ws.admin.core.jar %WAS_HOME%\runtimes\com.ibm.ws.admin.client_7.0.0.jar には CONNECTOR_TYPE_SOAP が必要です。CONNECTOR_TYPE_RMI が接続に失敗しました。スタック トレース メッセージに基づく jar の問題である可能性があります

public class JMXAdminClientSimple {

`private AdminClient adminClient; プライベート ObjectName nodeagent = null;

public void initialize() throws Exception {
    try {
        // Initialize the AdminClient.
        Properties props = new Properties();
          props.setProperty(AdminClient.CONNECTOR_HOST, "localhost");
          props.setProperty(AdminClient.CONNECTOR_PORT, "8880");
          props.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
          props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "false");
          props.setProperty(AdminClient.USERNAME, "");
          props.setProperty(AdminClient.PASSWORD, "");
          adminClient = AdminClientFactory.createAdminClient(props);

    } catch (Exception ex) {
        ex.printStackTrace(System.out);
        throw ex;
    }
}`    
于 2012-11-14T16:11:16.793 に答える
0

Sun/Oracle JRE でセキュリティを無効にして AdminClient API を使用するには、クラスパスに次の JAR が必要です。

  • runtimes/com.ibm.ws.admin.client_7.0.0.jar
  • runtimes/com.ibm.ws.ejb.thinclient_7.0.0.jar
  • runtimes/com.ibm.ws.orb_7.0.0.jar

これらの JAR を使用すると、RMI も機能するはずです。

于 2012-11-15T18:18:04.910 に答える