logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Calmus <m...@calmus.org>
Subject Re: Unable to lookup java:comp/env/log4j/context-name
Date Tue, 29 Dec 2015 18:11:28 GMT
The problem here seems to be that our web services were declaring and
instantiating their loggers as static instances. Because the web services
were being loaded by JBoss in a web service classloader and not the web
classloader this error occurs.

The solution is to not instantiate the Logger inline with its declaration.
Then, a @PostConstruct method is used to instantiate the Logger.

On Thu, Dec 10, 2015 at 3:09 PM, Mike Calmus <mike@calmus.org> wrote:

> We are moving from Weblogic (10g) to JBoss (EAP6).
>
> The server is set to use the JndiContextSelector. All the required
> properties are set in the web.xml.
>
> With apps that have EJBs or web services, JBoss seems to be initializing
> the code as it is being deployed. Because our base web service classes have
> Logger instances in them, these are also initialized during deployment.
> This seems to happen, though independently of the reading of the
> configuration paramters in the web.xml. As such, the log gets flooded with
> messages similar to this:
>
> ERROR Unable to lookup java:comp/env/log4j/context-name
> javax.naming.NameNotFoundException: java:comp/env/log4j/context-name
>        at
> org.jboss.as.naming.InitialContext$DefaultInitialContext.findContext(InitialContext.java:197)
>        at
> org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:241)
>        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183)
>        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
>        at javax.naming.InitialContext.lookup(InitialContext.java:417)
>        at javax.naming.InitialContext.lookup(InitialContext.java:417)
>        at
> org.apache.logging.log4j.core.net.JndiManager.lookup(JndiManager.java:128)
>        at
> org.apache.logging.log4j.core.selector.JndiContextSelector.getContext(JndiContextSelector.java:113)
>
> These message don't seem to be causing any actual problems with the
> application or deployment, but it would be nice to not have them.
>
> I've tried also adding the env-entry property to the ear's
> application.xml, but that seems not to be any more helpful.
>
> What can I do to eliminate these messages?
>
> We are using Log4j 2.4.1 with Java 8.
>
> Thank you.
>
> --
> Mike
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message