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

问题描述

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

情况是这样的:

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

但我需要自动化这一步,所以我为此创建了一个 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 异常? 这太疯狂了。

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

我错过了什么?

解决方法

在某些时候,oracle 已从使用 CLASSPATH 更改为 WLST_EXT_CLASSPATH 来设置 WLST 的类路径。不过,Oracle 似乎并没有很好地记录下这是正确的 env 变量。我通过挖掘 wlst.sh 调用的各种 sh 脚本找到了它,但是 12c 的 this 文档引用了它,但似乎是唯一提到它的地方。

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

,

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

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

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

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

第二个副本解决了 WLST 抛出的 class not found issue

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