2013-03-20 36 views
1

我正在使用IBM WebSphere服務器。我需要使用WebSphere Administrative API爲Java創建WebSphere管理客戶機程序。我使用this code創建管理客戶機爲Java創建WebSphere管理客戶端程序

... 
adminClient = AdminClientFactory.createAdminClient(connectProps); 
... 

但它提供了異常。

The system cannot create a SOAP connector to connect to host localhost at port 8881.

創建客戶端後,我想通過這個API來配置WASADMIN。我在正確的軌道上?

我需要通過此API獲取共享庫。

+0

你有沒有在本地主機上運行? – beny23 2013-03-20 14:03:17

+0

是的。它運行在本地主機 – 2013-03-20 14:16:36

回答

0

檢查,如果你有這樣的服務器SOAP連接器端口設置爲8881.

在DMGR單擊服務器名稱不是端口進行檢查。如果不使用8881,則將其更改爲正在嘗試連接的服務器所使用的正確端口。

更新:

我確實在我的環境(Linux)的測試和下面的代碼工作(我不得不添加WebSphere_ND8.5 /應用服務器/運行時/ com.ibm.ws.admin.client_8.5.0。 jarto類路徑運行它,而不會收到ClassNotFoundException異常):

import java.util.Properties; 
import java.util.logging.Logger; 

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

public class AdminConnect { 

private static Logger logger = Logger.getLogger(AdminConnect.class.getName()); 
/** 
* @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, "localhost"); 
    connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8880"); 
//  connectProps.setProperty(AdminClient.USERNAME, "test2"); 
//  connectProps.setProperty(AdminClient.PASSWORD, "user24test"); 
    AdminClient adminClient = null; 
    try 
    { 
      adminClient = AdminClientFactory.createAdminClient(connectProps); 
      logger.info("Connected successfuly with WebSphere :) "); 
    } 
    catch (ConnectorException e) 
    { 
      logger.severe("Exception creating admin client: " + e); 
      e.printStackTrace(); 
    } 

    } 

} 
+0

我檢查,並沒有問題與PORT。 – 2013-03-21 09:08:13

+0

你使用的是Linux盒子嗎?也許像iptables這樣的本地防火牆阻止你到達服務器。這真是個奇怪的問題。你也可以檢查WAS日誌SystemOut.log並檢查WIG中的地址嗎? (本地主機或DNS名稱?) – 2013-03-21 13:09:50

+0

使用XP。我嘗試使用本地主機和DNS名稱。 – 2013-03-21 13:56:35