logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Log4j2 Kafka appender NullPointerException when put the related jars in tomcat lib
Date Thu, 18 Aug 2016 23:40:03 GMT
Based on the stack trace, it looks like the Slf4j logger in KafkaProducer
is null:

        log.info("Closing the Kafka producer with timeoutMillis = {} ms.",
timeUnit.toMillis(timeout));

It does not look like timeUnit can be null, so it must be log.

The root problem of course if that we have an exception thrown in the
KafkaProducer
ctor.

Gary

On Thu, Aug 18, 2016 at 3:44 PM, Bill Okara <billokara@gmail.com> wrote:

> tried again, seemed like the .out extension got filtered out by mail
> server...
>
> On Thu, Aug 18, 2016 at 4:41 PM, Bill Okara <billokara@gmail.com> wrote:
> > attach the catalina.out again, didn't seem to go through last time...
> >
> >
> > On Thu, Aug 18, 2016 at 4:33 PM, Bill Okara <billokara@gmail.com> wrote:
> >> Hi,
> >>
> >> When trying out the log4j2 Kafka appender, it works ok if all the
> >> log4j2/kafka-client related jars are packaged in the webapp's
> >> WEB-INF/lib, like:
> >>
> >>>ls WEB-INF/lib/
> >> jackson-core-2.8.1.jar
> >> log4j-core-2.6.2.jar
> >> lz4-1.3.0.jar
> >> kafka-clients-0.10.0.1.jar
> >> log4j-slf4j-impl-2.6.2.jar
> >> slf4j-api-1.7.21.jar
> >> log4j-api-2.6.2.jar
> >> log4j-web-2.6.2.jar
> >> snappy-java-1.1.2.6.jar
> >>
> >>
> >> But if the jars are provided in tomcat/lib (for all webapps), and each
> >> webapp will have its own log4j2.xml (as in attached war), then when
> >> launching the webapp, will encounter:
> >>
> >> -----
> >> 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)
> >> ---------
> >>
> >> (full stack trace as in attached catalina.out)
> >>
> >>
> >> To reproduce the error, simply:
> >> 1) build the attached webapp, and deploy the output to tomcat/webapps
> >> 2) move the WEB-INF/lib/*.jar to tomcat/lib (make sure WEB-INF/lib is
> >> empty after move)
> >> 3) start tomcat
> >>
> >> Tested with tomcat 7.0.70
> >>
> >> Anyone encounter similar problem? or is this a bug? (log4j2 or
> >> kafka-client bug?)
> >>
> >>
> >> Thanks,
> >> Bill
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

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