You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2004/09/13 09:00:38 UTC

DO NOT REPLY [Bug 31192] New: - log4j should support delayed appender activation

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31192>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31192

log4j should support delayed appender activation

           Summary: log4j should support delayed appender activation
           Product: Log4j
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Configurator
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: binyan357@yahoo.com


I was trying to configure the JMSAppender for a client that was communicating
witha a jboss server.  If I configure the JMSAppender in code and add it to the
log4j configuration then all is fine.  However if I try and do it via a
properties file then I get a NPE.  The NPE is because of how log initializes
IMHO.  In my junit setup() method I created an IntialContext for jboss.  The
creation of the IntialContext causes the jboss org.jnp.interfaces.NamingContext
to be loader and it's static logger variable to attempt to initialize itsself
with a new Logger.  This seems to create a cycle where log4j now tries again to
create the JMSAppender and and eventually calls the activateOptions on the
JMSAppender class, which again creates a InitialContext and then tries to do a
lookup().  The lookup leads back into the NamingContext which results in a NPE
because one of its static variables has not been initialized because we have not
finished the original NamingContext initialization.

log4j:ERROR Error while activating options for appender named [jms].
java.lang.NullPointerException
	at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1190)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:515)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508)
	at javax.naming.InitialContext.lookup(InitialContext.java:347)
	at org.apache.log4j.net.JMSAppender.lookup(Unknown Source)
	at org.apache.log4j.net.JMSAppender.activateOptions(Unknown Source)
	at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:247)
	at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:123)
	at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:87)
	at
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:645)
	at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:603)
	at
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:500)
	at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:406)
	at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:432)
	at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
	at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
	at org.jboss.logging.Log4jLoggerPlugin.init(Log4jLoggerPlugin.java:63)
	at org.jboss.logging.Logger.getDelegatePlugin(Logger.java:320)
	at org.jboss.logging.Logger.<init>(Logger.java:78)
	at org.jboss.logging.Logger.getLogger(Logger.java:291)
	at org.jnp.interfaces.NamingContext.<clinit>(NamingContext.java:101)
	at
org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:41)
	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
	at javax.naming.InitialContext.init(InitialContext.java:219)
	at javax.naming.InitialContext.<init>(InitialContext.java:195)
	at com.intervoice.xa.logging.core.LoggingTest.setUp(LoggingTest.java:64)
	at junit.framework.TestCase.runBare(TestCase.java:125)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org