无法连接Prod OIM

时间:2017-04-19 00:59:11

标签: java weblogic11g oim

我有一个实际上能够连接到Lab OIM的代码但是相同的代码我无法连接到Prod OIM。以下是我正在使用的代码。我错过了什么吗?我在项目构建路径中也有所有这些Jars。帮助和任何建议将不胜感激。下面是调试类后我得到的代码和错误。

 public class ConnectionTest {
         UserManager userManager;

          public ConnectionTest() {
                  super();
                }
   public static void main(String[] arg) throws IOException, Exception {

    ConnectionTest oim=new ConnectionTest();
    oim.OIMConnection();
}
 public void OIMConnection(){             
    Hashtable<Object, Object> env = new Hashtable<Object, Object>();
    env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
    env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://hostname:port");
    System.setProperty("java.security.auth.login.config", "C:\\Documents\\authwl.conf");
    System.setProperty("OIM.AppServerType", "wls");  
    System.setProperty("APPSERVER_TYPE", "wls");
    oracle.iam.platform.OIMClient oimClient = new oracle.iam.platform.OIMClient(env);

    try {                        
        oimClient.login("username", "password".toCharArray());         
        logger.info("Successfully Connected with OIM!\n");
    } catch (LoginException e) {
        CharArrayWriter cw = new CharArrayWriter();
        PrintWriter w = new PrintWriter(cw);
        e.printStackTrace(w);
        logger.error("Login Exception: "+ cw.toString());
    }            
    userManager = oimClient.getService(UserManager.class);
}}

我得到的错误就在这里.....

登录异常:javax.security.auth.login.LoginException:[weblogic.socket.UnrecoverableConnectException:[登录失败,原因不明:P] at weblogic.security.auth.login.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:194 )     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:606)     在javax.security.auth.login.LoginContext.invoke(LoginContext.java:762)     在javax.security.auth.login.LoginContext.access $ 000(LoginContext.java:203)     在javax.security.auth.login.LoginContext $ 4.run(LoginContext.java:690)     在javax.security.auth.login.LoginContext $ 4.run(LoginContext.java:688)     at java.security.AccessController.doPrivileged(Native Method)     在javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:687)     在javax.security.auth.login.LoginContext.login(LoginContext.java:595)     在Thor.API.Security.LoginHandler.weblogicLoginHandler.login(weblogicLoginHandler.java:61)     在oracle.iam.platform.OIMClient.login(OIMClient.java:212)     在oracle.iam.platform.OIMClient.login(OIMClient.java:196)     在org.com.dis.exa.ConnectionTest.OIMConnection(ConnectionTest.java:73)     在org.com.dis.exa.ConnectionTest.main(ConnectionTest.java:53)

1 个答案:

答案 0 :(得分:0)

  1. 检查用户名和密码。
  2. 从Prod(非实验室)获取wlfullclient.jar。
  3. 检查C:\ Documents \ authwl.conf。这是Prod的文件?
  4. 参考我的样本:

    public static final String OIM_HOSTNAME = "oim.hpt.lab";
    public static final String OIM_PORT = "14000";
    public static final String OIM_PROVIDER_URL = "t3://"+ OIM_HOSTNAME + ":" + OIM_PORT;
    public static final String OIM_USERNAME = "tungpt";
    public static final String OIM_PASSWORD = "Hpt123456";
    public static final String OIM_CLIENT_HOME = "F:/designconsole11gr3/config";
    public static final String AUTHWL_PATH = OIM_CLIENT_HOME + "/authwl.conf";
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        OIMClient oimClient = null;
        try {
            //Set system properties required for OIMClient
            System.setProperty("java.security.auth.login.config", AUTHWL_PATH);
            System.setProperty("APPSERVER_TYPE", "wls");
    
            // Create an instance of OIMClient with OIM environment information  
            Hashtable env = new Hashtable();
            env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIM_PROVIDER_URL);
            oimClient = new OIMClient(env);
    
            // Login to OIM with the approriate credentials
            System.out.println("Login by: "+ OIM_USERNAME);
            oimClient.login(OIM_USERNAME, OIM_PASSWORD.toCharArray());
            System.out.println("Login Done!");
        }catch(Exception e){
            e.printStackTrace();
        }
    }