Running Log4j2 with Java 11 and Spring Boot causes NullPointerException


When my Spring Boot application starts up and initializes my Log4j2 logger in Java 11, I get the following exception:

2021-10-08 11:20:29,949 main INFO Cannot initialize scripting support because this JRE does not support it. java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "javax.script.ScriptEngine.get(String)" is null
at org.luaj.vm2.script.LuaScriptEngineFactory.getParameter(Unknown Source)
at org.apache.logging.log4j.core.script.ScriptManager.<init>(
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(
at org.apache.logging.log4j.core.LoggerContext.reconfigure(
at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(

There was another answer for the same problem a few years ago here: Log4j2/Slf4j and Java 11

However this answer from a few years ago, did not give me the steps I needed to figure out how to remove this. There was a discussion that it was an OpenJDK issue, and that it should be fixed now, but I am still struggling with this.

Does anyone understand this issue a bit more, why it only happens with Spring Boot, and what I can do to get rid of it in a clean way?


Your problem is different from the question you cite. Your classpath must contain the luaj-jse scripting engine, which has a bug:

    public Object getParameter(String key) {
        return getScriptEngine().get(key).toString();

When getParameter is called with a missing key (like "THREADING"), this causes a NullPointerException.

You should report this bug to LuaJ. In the meantime you can either ignore the error or remove luaj-jse from your dependencies.

Answered By – Piotr P. Karwasz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published