3

This is a first microservice I'm writing in Quarkus. Language: Kotlin

It's a simple service that reads data from LDAP DB based on some input parameters including mobile phone numbers. Everything works in jar build. In native build Google libphonenumber and Apache Directory Api are not working.

Quarkus extensions used: cdi, kotlin, resteasy, resteasy-jsonb, security, security-ldap

Libraries (maven) used: groupId:org.apache.directory.api, artifactId:api-all, version: 2.0.1 groupId: com.googlecode.libphonenumber, artifactId: libphonenumber, version: 8.12.14

Problems:

  1. Apache Directory Api: I'm using a connection pool:
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)

and using search method to search data:

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

In native build I'm getting this root exception:

Caused by: java.lang.NoSuchMethodException: sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory.<init>()
  1. Google libphone number just seems to not get input parameter and returns results as if null was sent as input.
val phoneNumberUtil = PhoneNumberUtil.getInstance()
...
phoneNumberUtil.parse(msisdn, defaultRegion),

Is there something that can be done for these to work. Or is it simply that these libraries don't work in native because they are using reflection or similar that Quarkus and Graal don't like?

Also if this is the case can you suggest LDAP library that will work on Quarkus, it has to support connection pooling.

Thank you

Melloware
  • 10,435
  • 2
  • 32
  • 62

2 Answers2

2

You need to include all the resources from LibPhoneNumber in your native image with this setting in application.properties

quarkus.native.resources.includes=**/phonenumbers/data/**
Melloware
  • 10,435
  • 2
  • 32
  • 62
0

In the end I replaced Apache Directory API with javax.naming.ldap and google libphonenumber with my own custom parser.

Now native build works.