lundi 21 juin 2021

Running fat jar vs sbt run

I am currently at a dead-end :)

So I have a project that I create a fat jar using sbt assembly. Then the intention is to run the jar using java -jar command. For testing purposes, I use sbt run which validates that everything works as expected. After that, I create a fat jar using sbt assembly. The problem is that the application crashes running the fat jar. sbt run works. java -jar app.jar fails. The error is not ClassNotFound or DefNotFound issue. Maybe it is not packaging a dependency correctly? I have investigated the issue various way and I even remote debugged the application to find out exact place the code fails on.

I have pasted the error for reference below.

Caused by: org.apache.kafka.common.config.ConfigException: HttpCredentialProvider not found for BASIC
    at io.confluent.security.auth.client.provider.BuiltInAuthProviders.loadHttpCredentialProviders(BuiltInAuthProviders.java:56)
    at io.confluent.security.auth.client.rest.RestClient.<init>(RestClient.java:117)
    at io.confluent.security.auth.client.rest.RestClient.<init>(RestClient.java:95)
    at io.confluent.kafka.clients.plugins.auth.token.TokenUserLoginCallbackHandler.configure(TokenUserLoginCallbackHandler.java:67)
    at io.confluent.kafka.clients.plugins.auth.token.AbstractTokenLoginCallbackHandler.configure(AbstractTokenLoginCallbackHandler.java:86)
    at org.apache.kafka.common.security.authenticator.LoginManager.<init>(LoginManager.java:60)
    at org.apache.kafka.common.security.authenticator.LoginManager.acquireLoginManager(LoginManager.java:105)
    at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:161)

After remote debugging and stepping into the code for a bit I found out that the code uses reflection.

        return new ServiceLoader<>(Reflection.getCallerClass(), service, loader);

The code is supposed to find BasicAuthCredentialProvider class. The jar tf -app.jar tells me that the jar contains that file. So this tells me that it is perhaps not a dependency issue. maybe I am wrong?

I then switched my Java versions from 8 to 11. No luck there either. I am running out of ideas. Does anyone have some other idea I could investigate?

enter image description here

enter image description here





Aucun commentaire:

Enregistrer un commentaire