Spring Cloud Stream header enricher circular reference and NPE

336 views Asked by At

Using Spring Cloud Data Flow Server and shell 1.3.0.M1, the Kafka binder, and loading apps from the Bacon bit-ly URL (1.2.0.RELEASE).

I created/deployed a stream in SCDF shell:

source | httpclient <args> | header-enricher --headers=\"key=payload\" | log

and received exception in the header-enricher log:

2017-08-29 16:37:16,991  WARN main o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext:550 - 
Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'org.springframework.cloud.stream.app.header.enricher.processor.
 HeaderEnricherProcessorConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'headerEnricher' defined in org.springframework.cloud.stream.app.header.enricher.processor.HeaderEnricherProcessorConfiguration: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.integration.transformer.HeaderEnricher]: Circular reference involving 
containing bean 
'org.springframework.cloud.stream.app.header.enricher.processor.
 HeaderEnricherProcessorConfiguration' - consider declaring the factory method as static 
 for independence from its containing instance. Factory method 'headerEnricher' 
 threw exception; nested exception is java.lang.NullPointerException

Also tried header-enricher --headers=token='\"foo\"' (string value) with the same result.

Am I doing something wrong?

2

There are 2 answers

0
user944849 On BEST ANSWER

I unregistered the header-enricher app from the Bacon.RELEASE (1.2.0) and replaced it with the latest snapshot (1.3.0.BUILD-SNAPSHOT) using these shell commands:

dataflow:>app unregister --name header-enricher --type processor
dataflow:>app register --name header-enricher --type processor 
  --uri maven://org.springframework.cloud.stream.app:header-enricher-processor-kafka-10:1.3.0.BUILD-SNAPSHOT

When I register my test stream using --headers='key=payload', and deploy it like this:

dataflow:>stream deploy test --properties "app.header-enricher.spring.cloud.stream.kafka.binder.headers=key"

all works as expected. The circular reference exception is gone, and I see the key header in the message received by the log sink. Perhaps the circular reference is a bug that has been corrected.

---- Update ----

Whatever the issue was appears to be corrected with the Celsius.M1 milestone release. The circular reference exception no longer occurs when I use that version of the app starters.

1
Ilayaperumal Gopinathan On

The header-enricher's option headers is of type Properties and you can specify the option as --headers='key=payload'