You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Prem Panchami <Pr...@nabler.com> on 2016/04/20 13:26:13 UTC

KafkaProducer NullPointerException

Hi,
We have a Kafka producer app that participates in the larger system. It worked fine sending messages. We just added our new tracing utility (uses SLF4J, LOG4J2) which has a couple of loggers that use Kafka appenders. Now we get a null pointer exception when we try to create KafkaProducer. If we remove all loggers from the Log4j2.xml it successfully constructs and proceeds as before.

We have tried various combinations of Maven exclusions. It only works when we effectively shunt our tracing utility. Any pointers on how we can have them coexist such that our producer app can use the common tracing utility?

Thanks in advance!
-p

Exception in thread "main" java.lang.ExceptionInInitializerError
at Producer.nPrepTestProducer.Sender.<init>(Sender.java:55)
at Producer.nPrepTestProducer.KafkaProducer.main(KafkaProducer.java:43)
Caused by: java.lang.NullPointerException
at org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:613)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:319)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:181)
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:98)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:225)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:492)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:562)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:578)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:214)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:145)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:182)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
at org.apache.kafka.clients.producer.KafkaProducer.<clinit>(KafkaProducer.java:125)
... 2 more

________________________________

*******NABLER******** CAUTION - Disclaimer *******NABLER********
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. NABLER has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. NABLER reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the NABLER e-mail system.
*** NABLER******** End of Disclaimer ********NABLER***

Re: KafkaProducer NullPointerException

Posted by R Krishna <kr...@gmail.com>.
Do you mind sharing your log4j2 xml and if you can run it with your version
separately as a simple standalone client?

On Wed, Apr 20, 2016 at 4:26 AM, Prem Panchami <Pr...@nabler.com> wrote:

> Hi,
> We have a Kafka producer app that participates in the larger system. It
> worked fine sending messages. We just added our new tracing utility (uses
> SLF4J, LOG4J2) which has a couple of loggers that use Kafka appenders. Now
> we get a null pointer exception when we try to create KafkaProducer. If we
> remove all loggers from the Log4j2.xml it successfully constructs and
> proceeds as before.
>
> We have tried various combinations of Maven exclusions. It only works when
> we effectively shunt our tracing utility. Any pointers on how we can have
> them coexist such that our producer app can use the common tracing utility?
>
> Thanks in advance!
> -p
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at Producer.nPrepTestProducer.Sender.<init>(Sender.java:55)
> at Producer.nPrepTestProducer.KafkaProducer.main(KafkaProducer.java:43)
> Caused by: java.lang.NullPointerException
> at
> org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:613)
> at
> org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:319)
> at
> org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:181)
> 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:98)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:225)
> at
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:492)
> at
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:562)
> at
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:578)
> at
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:214)
> at
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:145)
> at
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
> at org.apache.logging.log4j.LogManager.getContext(LogManager.java:182)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
> at
> org.apache.kafka.clients.producer.KafkaProducer.<clinit>(KafkaProducer.java:125)
> ... 2 more
>
> ________________________________
>
> *******NABLER******** CAUTION - Disclaimer *******NABLER********
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely for the use of the addressee(s). If you are not the intended
> recipient, please notify the sender by e-mail and delete the original
> message. Further, you are not to copy, disclose, or distribute this e-mail
> or its contents to any other person and any such actions are unlawful. This
> e-mail may contain viruses. NABLER has taken every reasonable precaution to
> minimize this risk, but is not liable for any damage you may sustain as a
> result of any virus in this e-mail. You should carry out your own virus
> checks before opening the e-mail or attachment. NABLER reserves the right
> to monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be stored
> on the NABLER e-mail system.
> *** NABLER******** End of Disclaimer ********NABLER***
>



-- 
Radha Krishna, Proddaturi
253-234-5657