Using Apache Jena with Kotlin, works in Idea, fails with Gradle


#1

Hello,

I’m starting with Kotlin and I’m trying to implement a really simple example using a Java library (Apache Jena).

When I run it from Idea, it works, and the program exits properly, when I run it after a gradle build and try to run the produced jar with java -jar, it fails with a NullPointerException coming from that Java library.

I’m trying to build a “fat-jar” so I can deploy that as a stand-alone app. If there are other ways to do, I would be really happy to hear them.

The project is here: https://github.com/bjonnh/kotlin_jena
and I get this error message:
https://gist.github.com/bjonnh/d01c862e95056bc8bf9fb8cf010dfd1c


#2

I found that running

import org.apache.jena.query.ARQ.init()

Solves this issue.

But still, if someone knows, I would like to know why this is failing with gradle and not in Idea.