【问题标题】:Exception while connecting weblogic server using EJB - Invalid Subject: principals=[weblogic, Administrators]使用 EJB 连接 weblogic 服务器时出现异常 - 无效的主题:principals=[weblogic, Administrators]
【发布时间】:2016-05-05 16:49:16
【问题描述】:

我有一个线程在我的本地 weblogic 服务器中运行,该线程每天运行一次,它尝试与运行在不同 weblogic 服务器中的另一个应用程序建立连接。每当我的方法创建一个远程对象并尝试调用远程方法时,我都会遇到异常

[Security:090398]无效的主题:principals=[weblogic, Administrators]

这是我的代码:

    Properties myEnv = new Properties();
    myEnv.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    myEnv.put(Context.PROVIDER_URL, "t3//123.345.234.123:1234");
    myEnv.put( Context.SECURITY_PRINCIPAL, username );
    myEnv.put( Context.SECURITY_CREDENTIALS, password );        
    InitialContext context;
    Object lookupObj;
    try {
        context = new InitialContext(_contextEnv);  
        lookupObj = context.lookup("ejb.lookup.bean");
        MyHome home = (MyHome) PortableRemoteObject.narrow(lookupObj, MyHome.class);
        MyRemote remote =home.create();
        if (null != context) {
            try {
                context.close();
            }
            catch (Exception e) {
            //

            }
        }
        return remote;
    }  catch (Exception e) {            
        e.printStackTrace();
    }

谁能告诉我怎么了?

【问题讨论】:

    标签: ejb weblogic subject


    【解决方案1】:

    我认为这两个 weblogic 服务器实例都在 2 个不同的域中运行。 因此,您需要启用两个域之间的信任。 看看这个文档:https://docs.oracle.com/cd/E21764_01/web.1111/e13707/domain.htm#SECMG402

    另外,当更需要时,不要忘记在 finally 子句中关闭 JNDI 上下文。

    【讨论】:

      【解决方案2】:

      就我而言,我只是添加参数

      -Dweblogic.security.crypto.verifyPriorDigest=true 
      -Dweblogic.security.crypto.generatePriorDigest=true
      

      到我的 JAVA_OPTIONS 和 Weblogic Server 12.2.1.4.0,例如,如果你使用 nodeMangerService,你可以编辑你的 startNodeManager.sh 并添加参数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-19
        • 2013-04-27
        • 2023-04-02
        • 1970-01-01
        相关资源
        最近更新 更多