[
https://issues.apache.org/jira/browse/LOG4J2-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15444318#comment-15444318
]
Bill Okara commented on LOG4J2-1535:
------------------------------------
actually the issue only happened if putting the log4j jars in tomcat/lib vs in
webapp/WEB-INF/lib (which worked ok). Details of the discussion are in the
external issue URL, and this jira was created as per requested (attached below
per reference)
From: Ralph Goers <[email protected]>
Subject: Re: Log4j2 Kafka appender NullPointerException when put the related
jars in tomcat lib
Date: 2016-08-19 15:17 (-0600)
List: [email protected]
So they are being kicked off by the webapp initialization. That follows what I
was thinking. I have a suspicion I may have to put in some code to check if the
logging classes are in the same ClassLoader as the current ClassLoader. If they
aren’t we probably need to kick off logging initialization there first and then
continue with the current initialization. I need to look at the code again and
try a few things though. Is it possible you could create a Jira for this and
attach a sample project that demonstrates the problem?
> KafkaAppender NullPointerException when putting the related jars in tomcat lib
> ------------------------------------------------------------------------------
>
> Key: LOG4J2-1535
> URL: https://issues.apache.org/jira/browse/LOG4J2-1535
> Project: Log4j 2
> Issue Type: Improvement
> Components: Appenders
> Affects Versions: 2.6.2
> Environment: Tomcat 7.0.70
> Reporter: Bill Okara
> Attachments: kafka-test-src.tar.gz
>
>
> By putting the log4j2 and kafka appender related jars in tomcat/lib (instead
> of packaged in WEB-INF/lib), got NullPointerException when initializing the
> log4j2.xml.
> Steps to reproduce:
> 1) unzip the attached kafka-test-src.tar.gz, build the project with maven:
> > mvn clean package
> 2) get all the dependency jars by:
> > mvn dependency:copy-dependencies
> 3) copy the *.jar from $project/target/dependency/*.jar to tomcat/lib/
> 4) deploy the war to tomcat
> 5) start tomcat
> Will see errors like:
> Caused by: java.lang.NullPointerException at
> org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:658)
> at
> org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:333)
> at
> org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:188)
> at
> org.apache.logging.log4j.core.appender.mom.kafka.DefaultKafkaProducerFactory.newKafkaProducer(DefaultKafkaProducerFactory.java:29)
> at
> org.apache.logging.log4j.core.appender.mom.kafka.KafkaManager.startup(KafkaManager.java:86)
> at
> org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender.start(KafkaAppender.java:96)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:247)
> at
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
> at
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:566)
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]