【问题标题】:WebLogic: add a new custom authentication-providers via WLST throws a ClassNotFoundExceptionWebLogic:通过 WLST 添加新的自定义身份验证提供程序会引发 ClassNotFoundException
【发布时间】:2021-06-10 10:53:18
【问题描述】:

我正在尝试使用 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 异常呢? 这太疯狂了。

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

我错过了什么?

【问题讨论】:

  • 您的 JAR 文件必须添加到 WLST 的类路径中。 $DOMAIN_HOME/lib 由服务器启动脚本使用,而不是与 WLST 一起使用。
  • JAR 在服务器类路径上。否则,我的自定义安全提供程序不会出现在 WL 控制台上。
  • 但是,如果我错了,请纠正我!
  • 服务器类路径不是 wlst 类路径。服务器类路径中的库,因此控制台能够部署您的自定义安全提供程序。如果要使用 WLST 执行此操作,则必须更新 WLST 脚本并更新类路径。

标签: java weblogic weblogic12c wlst


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    我将我的 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

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

    【讨论】:

      猜你喜欢
      • 2016-01-06
      • 2012-04-05
      • 1970-01-01
      • 2012-11-09
      • 2017-05-12
      • 1970-01-01
      • 2013-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多