Quarkus,Apache 目录 API,Google libphonenumber 库不适用于本机



这是我用Quarkus写的第一个微服务。语言:芬兰湾的科特林

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

使用的Quarkus扩展:cdi, kotlin, restasy, restasy -jsonb, security, security-ldap

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

问题:

  1. Apache Directory 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方法查找数据:

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

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

Caused by: java.lang.NoSuchMethodException: sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory.<init>()
  1. Google libphone number似乎没有得到输入参数,并返回结果,如果null作为输入发送。
val phoneNumberUtil = PhoneNumberUtil.getInstance()
...
phoneNumberUtil.parse(msisdn, defaultRegion),

有什么可以做这些工作。或者仅仅是因为这些库使用了Quarkus和Graal不喜欢的反射或类似的东西而不能在本机工作?

如果是这种情况,你能建议在Quarkus上工作的LDAP库吗?它必须支持连接池。

谢谢

您需要在application.properties

中使用此设置将LibPhoneNumber中的所有资源包含在本机映像中。
quarkus.native.resources.includes=**/phonenumbers/data/**

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

现在本机构建工作。

最新更新