WebLogic:通过 WLST 添加新的自定义身份验证提供程序会引发 ClassNotFoundException

问题描述 投票:0回答:2

我正在尝试使用 WLST 在线模式脚本添加新的自定义身份验证提供程序,但尽管我可以在 WL 控制台上看到我的提供程序,但我收到了未找到类的异常。

情况是这样的:

  1. 我有一个 JAR 文件,它包含一个自定义的 WebLogic 身份验证提供程序。
  2. JAR 复制到
    user_projects/domains/$DOMAIN_NAME/lib/
    目录下。
  3. 我可以在 WL 控制台上看到自定义身份验证提供程序,出现在列表中:
    Home > Security Realms > myrealm > Providers > new> Type
  4. 我可以通过 WL 控制台手动添加此自定义提供程序。

但我需要自动执行此步骤,因此我为此创建了一个 WLST 脚本。 WLST 的相关部分是这样的:

# add a new authentication provider with name of MyCustomAuthProvider
cd('/SecurityConfiguration/' + _domainName + '/Realms/myrealm')
cmo.createAuthenticationProvider('MyCustomAuthProvider', 'aa.bb.cc.MyCustomAuthProvider')

cd('/SecurityConfiguration/' + _domainName + '/Realms/myrealm/AuthenticationProviders/MyCustomAuthProvider')
cmo.setControlFlag('OPTIONAL')
    
# reorder authentication providers
...

但是这个 WLST 抛出以下异常:

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: aa.bb.cc.MyCustomAuthProvider

所以我仔细检查了 WL 是否看到我的自定义身份验证提供程序:

wls:/offline> connect('weblogic', 'weblogic12', 't3://localhost:7001')
cd('/SecurityConfiguration/myDomain/Realms/myrealm')
ls()

我得到的名单和我预想的一模一样:我的班级在名单上。这就是我可以使用 Web 控制台添加它的原因。

这是 AuthenticationProviderTypes 的值:

java.lang.String[com.bea.security.saml2.providers.SAML2IdentityAsserter,
aa.bb.cc.MyCustomAuthProvider,
eblogic.security.providers.authentication.ActiveDirectoryAuthenticator,
weblogic.security.providers.authentication.CustomDBMSAuthenticator,
eblogic.security.providers.authentication.DefaultAuthenticator,
weblogic.security.providers.authentication.DefaultIdentityAsserter, 
eblogic.security.providers.authentication.IPlanetAuthenticator,
weblogic.security.providers.authentication.LDAPAuthenticator,
weblogic.security.providers.authentication.LDAPX509IdentityAsserter,
weblogic.security.providers.authentication.NegotiateIdentityAsserter,
weblogic.security.providers.authentication.NovellAuthenticator,
weblogic.security.providers.authentication.OpenLDAPAuthenticator,
weblogic.security.providers.authentication.OracleIdentityCloudIntegrator,
weblogic.security.providers.authentication.OracleInternetDirectoryAuthenticator,
weblogic.security.providers.authentication.OracleUnifiedDirectoryAuthenticator,
weblogic.security.providers.authentication.OracleVirtualDirectoryAuthenticator,
weblogic.security.providers.authentication.ReadOnlySQLAuthenticator,
weblogic.security.providers.authentication.SQLAuthenticator,
weblogic.security.providers.authentication.VirtualUserAuthenticator,
weblogic.security.providers.saml.SAMLAuthenticator,
weblogic.security.providers.saml.SAMLIdentityAsserterV2]

一切看起来都很完美。但是为什么 WLST 在尝试创建它时会抛出

class not found
异常呢? 这太疯狂了。

我已经用谷歌搜索过这个问题,但只有我发现的相同问题没有解决方案。

我错过了什么?

java weblogic weblogic12c wlst
2个回答
1
投票

在某些时候,oracle 已从使用

CLASSPATH
更改为
WLST_EXT_CLASSPATH
来设置 WLST 的类路径。 Oracle 似乎并没有很好地证明这是正确使用的环境变量。我通过挖掘 wlst.sh 调用的各种 sh 脚本找到了它,但是 12c 的 this 文档引用了它,但似乎是唯一提到它的地方。

我已经使用 14.1.1 和 DOMAIN/lib/mbeantypes 目录中的自定义提供程序对此进行了测试,它可以工作(即,只要我先设置 WLST_EXT_CLASSPATH,我就可以使用 WLST 来配置自定义安全提供程序),但没有12c 来测试它是否在那里工作。


0
投票

我将 JAR 添加到 WLST 类路径,但这没有帮助。

  • 我更改了
    CLASSPATH
    变量,因为
    wlst.sh
    在后台执行 java 命令,因此必须考虑此标准变量。没成功。
  • 我手动将
    -cp
    JVM 参数添加到启动 WlST 的 java 命令中。没成功。

对我有用的唯一解决方法是:

  • 对于 WL 控制台:将包含自定义身份验证提供程序的 JAR 复制到
    $ORACLE_HOME/user_projects/domains/$DOMAIN_NAME/lib/
    目录下
  • 对于 WLST:将 JAR 复制到
    $ORACLE_HOME/wlserver/server/lib/mbeantypes/

第二个副本解决了WLST抛出的

class not found issue

如果你知道更好、更标准的方法,请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.