Hi,

What happens if you use 2.14.0?

Gary

On Wed, Nov 24, 2021, 07:51 Tenghuan He <tenghua...@gmail.com> wrote:

> Hi, log4j community.
>
> Our application failed to start up due to the following error
>
> Caused by: java.lang.NullPointerException
>         at
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:144)
> ~[log4j-core-2.5.jar:2.5]
>         at
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
> ~[log4j-core-2.5.jar:2.5]
>         at
> org.apache.logging.log4j.LogManager.getContext(LogManager.java:182)
> ~[log4j-api-2.5.jar:2.5]
>         at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
> ~[log4j-api-2.5.jar:2.5]
>         at
> org.apache.logging.log4j.jul.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:34)
> ~[log4j-jul-2.5.jar:2.5]
>         at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
> ~[log4j-api-2.5.jar:2.5]
>         at
> org.apache.logging.log4j.jul.LogManager.getLogger(LogManager.java:89)
> ~[log4j-jul-2.5.jar:2.5]
>         at java.util.logging.LogManager.demandLogger(LogManager.java:551)
> ~[?:1.8.0_171]
>         at java.util.logging.Logger.demandLogger(Logger.java:455)
> ~[?:1.8.0_171]
>         at java.util.logging.Logger.getLogger(Logger.java:502)
> ~[?:1.8.0_171]
>         at
> com.google.inject.internal.util.Stopwatch.<clinit>(Stopwatch.java:27)
> ~[guice-4.1.0.jar:?]
>         ... 18 more
>
> We are using log4j-2.5, line#140 in the code snippet below `ctx` is
> returned as `null`, line#144 throws out the NPE.
>
> Diving into selector implementation, it seems that all kinds of
> selectors are trying to ensure no-null value is returned, so how could
> this happen?
>
> 137    @Override
> 138    public LoggerContext getContext(final String fqcn, final
> ClassLoader loader, final Object externalContext,
> 139                                    final boolean currentContext) {
> 140        final LoggerContext ctx = selector.getContext(fqcn, loader,
> currentContext);
> 141        if (externalContext != null && ctx.getExternalContext() ==
> null) {
> 142            ctx.setExternalContext(externalContext);
> 143        }
> 144        if (ctx.getState() == LifeCycle.State.INITIALIZED) {
> 145            ctx.start();
> 146        }
> 147        return ctx;
> 148    }
>
>
> Could anyone help?
>
> Thanks % Best Regards.
>

Reply via email to