LOG4J2 LogManager nullpointer exception on startup app

384 views Asked by At

I have one app running in an old server Solaris 10. In this server, after migrate log4j1 to log4j2 we start to get an error while start the app.

2022-08-04 15:02:52,994 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@4cf777e8 OK
2022-08-04 15:02:53,051 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69
2022-08-04 15:02:53,053 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=StatusLogger
2022-08-04 15:02:53,055 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=ContextSelector
2022-08-04 15:02:53,056 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=Loggers,name=com.infineon.logicload
2022-08-04 15:02:53,056 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=Loggers,name=
2022-08-04 15:02:53,057 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=Appenders,name=AFile
2022-08-04 15:02:53,058 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=Appenders,name=errorAppender
2022-08-04 15:02:53,058 main DEBUG Registering MBean org.apache.logging.log4j2:type=3d4eac69,component=Appenders,name=AConsole
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
        at java.lang.System.arraycopy(Native Method)
        at java.lang.String.getChars(String.java:826)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:449)
        at java.lang.StringBuilder.append(StringBuilder.java:136)
        at org.apache.logging.log4j.util.StringBuilders.appendSpecificTypes(StringBuilders.java:79)
        at org.apache.logging.log4j.message.ParameterFormatter.appendSpecialTypes(ParameterFormatter.java:484)
        at org.apache.logging.log4j.message.ParameterFormatter.recursiveDeepToString(ParameterFormatter.java:473)
        at org.apache.logging.log4j.message.ParameterFormatter.recursiveDeepToString(ParameterFormatter.java:448)
        at org.apache.logging.log4j.message.ParameterFormatter.formatMessage2(ParameterFormatter.java:191)
        at org.apache.logging.log4j.message.ParameterizedMessage.formatTo(ParameterizedMessage.java:227)
        at org.apache.logging.log4j.message.ParameterizedMessage.getFormattedMessage(ParameterizedMessage.java:203)
        at org.apache.logging.log4j.message.ParameterizedNoReferenceMessageFactory.newMessage(ParameterizedNoReferenceMessageFactory.java:105)
        at org.apache.logging.log4j.message.AbstractMessageFactory.newMessage(AbstractMessageFactory.java:91)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2051)
        at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1923)
        at org.apache.logging.log4j.spi.AbstractLogger.debug(AbstractLogger.java:468)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:700)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
        at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:599)
        at com.infineon.logicload.LogicLoad.<clinit>(LogicLoad.java:55)

In this app we set the logger properties using the java arguments

log4j2.configurationFile="cfg/logger.properties"

as we can see in the firsts lines of the log, the configuration file was loaded correctly.

Running in a linux server, our development machine, this error not ocour, and the log files is like this:

2022-08-03 16:45:51,495 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@2353b3e6 OK
2022-08-03 16:45:51,575 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057
2022-08-03 16:45:51,577 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=StatusLogger
2022-08-03 16:45:51,578 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=ContextSelector
2022-08-03 16:45:51,578 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=Loggers,name=com.infineon.logicload
2022-08-03 16:45:51,579 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=Loggers,name=
2022-08-03 16:45:51,579 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=Appenders,name=AFile
2022-08-03 16:45:51,580 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=Appenders,name=errorAppender
2022-08-03 16:45:51,581 main DEBUG Registering MBean org.apache.logging.log4j2:type=55054057,component=Appenders,name=AConsole
2022-08-03 16:45:51,582 main DEBUG Reconfiguration complete for context[name=55054057] at URI /workspaces/ebsprep-logicload/app/cfg/logger.properties (org.apache.logging.log4j.core.LoggerContext@4e268090) with optional ClassLoader: null
2022-08-03 16:45:51,583 main DEBUG Shutdown hook enabled. Registering a new one.
2022-08-03 16:45:51,583 main DEBUG LoggerContext[name=55054057, org.apache.logging.log4j.core.LoggerContext@4e268090] started OK.

I already check the java, ant and libs versions, but I can't find any significant diference that can impact my application.

I need ideas of what I can tray to solve this issue...

0

There are 0 answers