AdminClient Websphere NoClassDefFoundError

时间:2016-05-24 09:50:01

标签: java-ee websphere-liberty

我正在尝试从Websphere Application Server连接到远程Websphere Deployment Manager。为此,我使用的是Websphere AdminClient,但是当我尝试运行此代码时,我不断收到错误java.lang.NoClassDefFoundError:com / ibm / websphere / management / AdminClientFactory:

props = new Properties();
props.setProperty(AdminClient.CONNECTOR_HOST, hostname);
props.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
props.setProperty(AdminClient.CONNECTOR_PORT, "8880");
props.setProperty(AdminClient.USERNAME, "<username>");
props.setProperty(AdminClient.PASSWORD, "<password>");
props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
try {
    adminClient = AdminClientFactory.createAdminClient(props);
} catch (Exception e) {
    // TODO Auto-generated catch block
    System.out.println("Something went wrong");
    e.printStackTrace();
}

我已将com.ibm.ws.admin.client_8.5.0.jar添加到项目中。

此处还有我在开始时的进口

import java.util.Properties;
import com.ibm.websphere.management.*;
import com.ibm.websphere.management.exception.ConnectorException;

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:2)

我似乎已经自己解决了这个问题。 如果有人遇到类似问题,请将com.ibm.ws.admin.client_x.x.x.jar添加到WEB-INF / lib文件夹