Service Loader not load its implementation spring boot gradle.kts

48 views Asked by At

I'm using Jxls library to generate excel file. When I build the jar file got error

[onPool-worker-2] k.g.n.e.handler.GlobalErrorAttributes : java.lang.NullPointerException: Cannot invoke "org.jxls.expression.ExpressionEvaluatorFactory.createExpressionEvaluator(String)" because the return value of "org.jxls.util.JxlsHelper$ExpressionEvaluatorFactoryHolder.access$100()

After debugging I noted that the service loader for Jxls library got null

val iterator: Iterator<T> = ServiceLoader.load(interfaceClass).iterator()
        service = if (iterator.hasNext()) {
            iterator.next()
        }

I tried to reproduce it in another project but It doesn't having this issue. I tried to make the error project configuration match as much as possible with the project that doesn't error but still got the same error. Is there any configuration that make service loader can not load SPI file? I'm using gradle.kts file and here is my dependency embed

implementation("org.apache.poi:poi:5.0.0")
implementation("org.apache.poi:poi-ooxml:5.0.0")
implementation("org.jxls:jxls-poi:2.13.0")
0

There are 0 answers