Binder configuration error
See original GitHub issueCreating a simple producer application like this:
@SpringBootApplication
@EnableBinding(KafkaStreamProducerTestApplication.TestBinding.class)
public class KafkaStreamProducerTestApplication {
public static void main(String[] args) {
SpringApplication.run(KafkaStreamProducerTestApplication.class, args);
}
@RestController
@RequestMapping("test")
public class TestController {
@Autowired
private TestService testService;
@RequestMapping(path = "stream/{message}", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public ResponseEntity<?> stream(@PathVariable(name="message") String message) {
ResponseEntity<?> response = ResponseEntity.ok().build();
try {
testService.stream(message);
} catch (Exception e) {
response = ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(ExceptionUtils.getStackTrace(e));
}
return response;
}
}
@Service
public static class TestService {
private TestBinding testBinding;
public TestService(TestBinding testBinding) {
this.testBinding = testBinding;
}
public void stream(String message) {
testBinding.outboundEmails().send(new GenericMessage<String>(message));
}
}
public interface TestBinding {
String OUTPUT = "test-out";
@Output(OUTPUT)
MessageChannel outboundEmails();
}
}
application.yml:
spring:
cloud:
stream:
kafka:
binder:
brokers: localhost:9092
bindings:
test-out:
destination: "test"
build.gradle
buildscript {
dependencies {
classpath (group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '2.0.3.RELEASE')
}
}
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'stream-tests'
version = '0.0.1-SNAPSHOT'
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-starter-parent:2.0.3.RELEASE'
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.RELEASE'
}
}
dependencies {
compile (group: 'org.springframework.boot', name: 'spring-boot-devtools')
compile (group: 'org.springframework.boot', name: 'spring-boot-autoconfigure')
compile (group: 'org.springframework.boot', name: 'spring-boot-starter-web')
compile (group: 'org.springframework.boot', name: 'spring-boot-starter-actuator')
compile (group: 'org.springframework.cloud', name: 'spring-cloud-stream')
compile (group: 'org.springframework.cloud', name: 'spring-cloud-stream-binder-kafka-streams')
compile (group: 'org.apache.kafka', name: 'kafka-streams', version: '1.1.0')
compile (group: 'org.jolokia', name: 'jolokia-core', version: '1.5.0')
compile (group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '5.1')
compile (group: 'org.apache.commons', name: 'commons-lang3', version: '3.7')
// testCompile (group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-support')
testCompile (group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.15', classifier: 'indy')
testCompile (group: 'org.springframework.boot', name: 'spring-boot-starter-test')
testCompile (group: 'org.spockframework', name: 'spock-spring', version: '1.1-groovy-2.4')
testCompile (group: 'org.spockframework', name: 'spock-core', version: '1.1-groovy-2.4')
/*
* XXX: Necessary for now, see https://docs.spring.io/spring-kafka/reference/htmlsingle/#deps-for-11x
*/
compile (group: 'org.springframework.kafka', name: 'spring-kafka', version: '2.1.7.RELEASE')
testCompile (group: 'org.springframework.kafka', name: 'spring-kafka-test', version: '2.1.7.RELEASE')
testCompile (group: 'log4j', name: 'log4j', version: '1.2.17')
compile (group: 'org.apache.kafka', name: 'kafka-clients', version: '1.1.0')
compile ('org.apache.kafka:kafka-clients:1.1.0:test@jar')
testCompile ('org.apache.kafka:kafka_2.11:1.1.0')
testCompile ('org.apache.kafka:kafka_2.11:1.1.0:test@jar')
}
Gives me an exception:
org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is java.lang.IllegalStateException: A default binder has been requested, but there is more than one binder available for 'org.springframework.integration.channel.DirectChannel' : , and no default binder has been set.
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:184)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:885)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
at spring.cloud.stream.kafka.test.KafkaStreamProducerTestApplication.main(KafkaStreamProducerTestApplication.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: A default binder has been requested, but there is more than one binder available for 'org.springframework.integration.channel.DirectChannel' : , and no default binder has been set.
at org.springframework.cloud.stream.binder.DefaultBinderFactory.getBinder(DefaultBinderFactory.java:127)
at org.springframework.cloud.stream.binding.BindingService.getBinder(BindingService.java:308)
at org.springframework.cloud.stream.binding.BindingService.bindProducer(BindingService.java:208)
at org.springframework.cloud.stream.binding.BindableProxyFactory.bindOutputs(BindableProxyFactory.java:252)
at org.springframework.cloud.stream.binding.OutputBindingLifecycle.doStartWithBindable(OutputBindingLifecycle.java:46)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.start(AbstractBindingLifecycle.java:47)
at org.springframework.cloud.stream.binding.OutputBindingLifecycle.start(OutputBindingLifecycle.java:29)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
... 19 common frames omitted
If I uncomment the test-support depedency I can start the application and it works, but messages will be sent to Kafka, as a test binder is taking over.
What am I doing wrong here?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Spring cloud stream multi binder - Stack Overflow
This error occurred for me while I was using @SpringBootApplication and @EnableBinding( Processor.class ) outside of the class that was ...
Read more >Binder Error Message Control - GNAT User's Guide for Native ...
4.2.2 Binder Error Message Control. The following switches provide control over the generation of error messages from the binder: -v: Verbose mode.
Read more >5. Programming Model - Spring
If no internal error handlers are configured, the errors propagate to the binders, and the binders subsequently propagate those errors back to the...
Read more >Failed to create consumer binding Error — Solace Community
o.s.cloud.stream.binding.BindingService : Failed to create consumer binding; retrying in 30 seconds org.springframework.cloud.stream.binder.
Read more >How to fix Mass Assignment: Insecure Binder Configuration ...
This looks like an unfortunate false positive. The rule behind this error is made to avoid that properties present in an object but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nikolajbrinch Looks like you are using the wrong binder in your
build.gradle
. Instead of usingcompile (group: 'org.springframework.cloud', name: 'spring-cloud-stream-binder-kafka-streams')
, you need to usecompile (group: 'org.springframework.cloud', name: 'spring-cloud-stream-binder-kafka')
i get the same problem,after replace this dependency , it work.