【问题标题】:Quarkus, Apache directory api, google libphonenumber libraries don't work on nativeQuarkus、Apache 目录 api、google libphonenumber 库不适用于本机
【发布时间】:2021-04-20 07:12:29
【问题描述】:

这是我在 Quarkus 中编写的第一个微服务。 语言:科特林

这是一个简单的服务,它根据一些输入参数(包括手机号码)从 LDAP DB 中读取数据。 一切都在 jar 构建中工作。在本机构建中,Google libphonenumber 和 Apache Directory Api 不起作用。

使用的 Quarkus 扩展:cdi、kotlin、resteasy、resteasy-jsonb、security、security-ldap

使用的库(maven): groupId:org.apache.directory.api,artifactId:api-all,版本:2.0.1 groupId:com.googlecode.libphonenumber,artifactId:libphonenumber,版本:8.12.14

问题:

  1. Apache 目录 API: 我正在使用连接池:
val config = LdapConnectionConfig().apply {
  ...
}
// LDAP Connection Factory
val factory = DefaultLdapConnectionFactory(config).apply {
    setTimeOut(this@LdapConnectionPoolFactoryImpl.conf.ldap.pool.timeout)
}
// LDAP pool optional configuration
val poolConfig = GenericObjectPoolConfig<LdapConnectionPool>().apply {
    maxTotal                       = conf.ldap.pool.maxTotal
    ...
    ...
}
pool = LdapConnectionPool(DefaultPoolableLdapConnectionFactory(factory), poolConfig)

并使用搜索方法搜索数据:

search(conf.dao.searchBaseDn.msisdn, "(cn=$msisdn)", SearchScope.ONELEVEL, ::msisdnFrom)

在本机构建中,我得到了这个根异常:

Caused by: java.lang.NoSuchMethodException: sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory.<init>()
  1. Google libphone 号码似乎没有获取输入参数并返回结果,就好像 null 作为输入发送一样。
val phoneNumberUtil = PhoneNumberUtil.getInstance()
...
phoneNumberUtil.parse(msisdn, defaultRegion),

有什么办法可以让这些工作。或者仅仅是这些库不能在原生环境中工作,因为它们使用了 Quarkus 和 Graal 不喜欢的反射或类似功能?

如果是这种情况,您能否推荐适用于 Quarkus 的 LDAP 库,它必须支持连接池。

谢谢

【问题讨论】:

    标签: quarkus


    【解决方案1】:

    最后,我用 javax.naming.ldap 替换了 Apache Directory API,用我自己的自定义解析器替换了 google libphonenumber。

    现在原生构建工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-09
      • 2015-11-18
      • 2013-01-21
      • 2023-02-09
      相关资源
      最近更新 更多