1

我正在尝试为 websphere 创建一个管理客户端程序,但是当我尝试连接时,我收到以下消息。

也许我缺少一些库(我在记事本中创建我的应用程序)。

at TryConnection1.main(TryConnection1.java:37) Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.security.auth.WSL oginFailedException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

我的代码:

import java.util.Properties;
import javax.management.MalformedObjectNameException; 
import javax.management.ObjectName; 

import javax.management.*;
import com.ibm.websphere.management.*; 
import com.ibm.websphere.management.AdminClient; 
import com.ibm.websphere.management.AdminClientFactory; 
import com.ibm.websphere.management.exception.*;

import com.ibm.websphere.management.exception.ConnectorException;

public class TryConnection1 {

    /**  * @param args  */

    public static void main(String[] args) {

    Properties connectProps = new Properties(); 
    connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);

    connectProps.setProperty(AdminClient.CONNECTOR_HOST, "hostgoeshere");
    connectProps.setProperty(AdminClient.CONNECTOR_PORT, "portgoeshere");
    connectProps.setProperty(AdminClient.USERNAME, "usernamegoeshere");
    connectProps.setProperty(AdminClient.PASSWORD, "passgoeshere");

    AdminClient adminClient = null; 
    try {
        adminClient = AdminClientFactory.createAdminClient(connectProps); 
    } catch(ConnectorException e) {
        System.out.println("Exception creating admin client: " + e); }
    }
}
4

2 回答 2

2

如果您使用不同的 WebSphere 版本,请尝试将 $WEBSPHERE_HOME/AppServer/runtimes/com.ibm.ws.admin.client_8.5.0.jar 或类似内容添加到您的类路径中。这是 WebSphere Admin Client 所需的 jar。

于 2013-03-26T12:32:38.440 回答
0

您应该尝试添加:

import com.ibm.websphere.security.auth.*;
于 2013-03-26T07:50:56.453 回答