0

I was following this answer to create an executable JAR using Maven. However, I came up with the following error:

> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.ExceptionInInitializerError
    at me.vijaychavda.rdfr.Reifier.do_reify(Reifier.java:82)
    at me.vijaychavda.rdfr.Reifier.reify(Reifier.java:63)
    at me.vijaychavda.rdfr.Reifier.reify(Reifier.java:73)
    at me.vijaychavda.rdfr.Main.main(Main.java:30)
Caused by: java.lang.NullPointerException
    at org.apache.jena.tdb.sys.EnvTDB.processGlobalSystemProperties(EnvTDB.java:33)
    at org.apache.jena.tdb.TDB.init(TDB.java:249)
    at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29)
    at org.apache.jena.system.JenaSystem.lambda$init$2(JenaSystem.java:119)
    at java.util.ArrayList.forEach(ArrayList.java:1255)
    at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:194)
    at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:171)
    at org.apache.jena.system.JenaSystem.init(JenaSystem.java:117)
    at org.apache.jena.rdf.model.ModelFactory.<clinit>(ModelFactory.java:49)
    ... 4 more

This answer helped me to get rid of SLF4J error, but after adding the dependency, I still get this error:

> Exception in thread "main" java.lang.ExceptionInInitializerError
    at me.vijaychavda.rdfr.Reifier.do_reify(Reifier.java:82)
    at me.vijaychavda.rdfr.Reifier.reify(Reifier.java:63)
    at me.vijaychavda.rdfr.Reifier.reify(Reifier.java:73)
    at me.vijaychavda.rdfr.Main.main(Main.java:30)
Caused by: java.lang.NullPointerException
    at org.apache.jena.tdb.sys.EnvTDB.processGlobalSystemProperties(EnvTDB.java:33)
    at org.apache.jena.tdb.TDB.init(TDB.java:249)
    at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29)
    at org.apache.jena.system.JenaSystem.lambda$init$2(JenaSystem.java:119)
    at java.util.ArrayList.forEach(ArrayList.java:1255)
    at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:194)
    at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:171)
    at org.apache.jena.system.JenaSystem.init(JenaSystem.java:117)
    at org.apache.jena.rdf.model.ModelFactory.<clinit>(ModelFactory.java:49)
    ... 4 more

My project is using Apache's Jena library.

Actually I'm new to Maven, and I just want to create executable JAR for my Java project :)

EDIT 1:

I also tried this and this method of using the Shade plugin, but same error!

EDIT 2: The code runs fine without any errors. These errors come when I try to create the JAR.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Vijay Chavda
  • 826
  • 2
  • 15
  • 34

1 Answers1

0

It looks like you have not shaded all the service loader files into your combined jar:

https://jena.apache.org/documentation/notes/jena-repack.html

https://jena.apache.org/documentation/notes/system-initialization.html

AndyS
  • 16,345
  • 17
  • 21