logging-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikael Ståldal (JIRA) <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1535) KafkaAppender NullPointerException when putting the related jars in tomcat lib
Date Wed, 04 Oct 2017 19:35:01 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16191891#comment-16191891
] 

Mikael Ståldal commented on LOG4J2-1535:
----------------------------------------

[~Flowcont] Which version of Kafka client are you using?


> 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: Core
>    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) 
> So this issue is triggered by the fact that the Kafka client library we use itself does
logging via SLF4J during initialization. And in this particular web configuration, org.slf4j.LoggerFactory.getLogger(Class)
return null during Configuration.start().



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message