0

我正在尝试使用 MBean 监视 Websphere 7 环境,但遇到了许多问题。首先,使用下面发布的代码时,我收到以下异常:

com.ibm.websphere.management.exception.ConnectorException:无法创建 RMI 连接器以连接到端口 2809 上的主机 localhost

这是生成异常的代码:

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

请注意,我可以通过 WSadamin 和包含以下内容的 Java prog 两种方式联系端口 2809:

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

要在 Sun/Oracle JRE 上使用禁用安全性的 AdminClient API,您需要在类路径中包含以下 JAR:

  • 运行时/com.ibm.ws.admin.client_7.0.0.jar
  • 运行时/com.ibm.ws.ejb.thinclient_7.0.0.jar
  • 运行时/com.ibm.ws.orb_7.0.0.jar

使用这些 JAR,RMI 也应该可以工作。

于 2012-11-15T18:18:04.910 回答
0

使用以下示例代码片段和符号解决了我的问题。注意,特别注意抛出的异常和消息:mssing 类;即专注于消息“无法创建”消息可能会误导您

需要以下 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 问题

公共类 JMXAdminClientSimple {

`private AdminClient adminClient; 私有对象名节点代理 = 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 回答