spring-cloud / spring-cloud-stream-samples

Samples for Spring Cloud Stream
Apache License 2.0
956 stars 676 forks source link

schema-registry-vanilla-kafka-binder: Field customSerde in sample.consumer.CountVersionApplication required a single bean, but 2 were found: #175

Open eskuai opened 4 years ago

eskuai commented 4 years ago

Hi,

As a user, i am testing samples from schema-registry-vanilla-kafka-binder-

Schema registry starts ok

[ec2-user@k8s-master tmp]$ java -jar schema-registry-server.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.1.RELEASE)

2020-02-17 15:09:58.842  INFO 14044 --- [           main] .c.s.r.s.SchemaRegistryServerApplication : Starting SchemaRegistryServerApplication v1.0.0.BUILD-SNAPSHOT on k8s-master with PID 14044 (/tmp/schema-registry-server.jar started by ec2-user in /tmp)
2020-02-17 15:09:58.847  INFO 14044 --- [           main] .c.s.r.s.SchemaRegistryServerApplication : No active profile set, falling back to default profiles: default
2020-02-17 15:09:59.607  INFO 14044 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-02-17 15:09:59.673  INFO 14044 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 54ms. Found 1 repository interfaces.
2020-02-17 15:10:00.229  INFO 14044 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-17 15:10:00.614  INFO 14044 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8990 (http)
2020-02-17 15:10:00.627  INFO 14044 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-17 15:10:00.627  INFO 14044 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.27]
2020-02-17 15:10:00.691  INFO 14044 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-02-17 15:10:00.691  INFO 14044 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1724 ms
2020-02-17 15:10:00.858  INFO 14044 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-02-17 15:10:01.179  INFO 14044 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-02-17 15:10:01.260  INFO 14044 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-02-17 15:10:01.385  INFO 14044 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.4.8.Final}
2020-02-17 15:10:01.582  INFO 14044 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-02-17 15:10:01.740  INFO 14044 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-02-17 15:10:02.606  INFO 14044 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-02-17 15:10:02.614  INFO 14044 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-17 15:10:03.068  WARN 14044 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-17 15:10:03.218  INFO 14044 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-17 15:10:03.469  INFO 14044 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8990 (http) with context path ''
2020-02-17 15:10:03.471  INFO 14044 --- [           main] .c.s.r.s.SchemaRegistryServerApplication : Started SchemaRegistryServerApplication in 5.28 seconds (JVM running for 5.926)

But consumer shows:

[ec2-user@k8s-master schema-registry-vanilla-kafka-binder]$ java -jar kafka-streams-consumer/target/kafka-streams-consumer-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::  (v2.2.0.BUILD-SNAPSHOT)

2020-02-17 15:11:09.695  INFO 15286 --- [           main] sample.consumer.CountVersionApplication  : Starting CountVersionApplication v0.0.1-SNAPSHOT on k8s-master with PID 15286 (/home/ec2-user/spring-cloud-stream-samples/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/target/kafka-streams-consumer-0.0.1-SNAPSHOT.jar started by ec2-user in /home/ec2-user/spring-cloud-stream-samples/schema-registry-samples/schema-registry-vanilla-kafka-binder)
2020-02-17 15:11:09.701  INFO 15286 --- [           main] sample.consumer.CountVersionApplication  : No active profile set, falling back to default profiles: default
2020-02-17 15:11:10.978  INFO 15286 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2020-02-17 15:11:10.992  INFO 15286 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2020-02-17 15:11:11.076  INFO 15286 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-17 15:11:11.100  INFO 15286 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-17 15:11:11.102  INFO 15286 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-17 15:11:11.542  INFO 15286 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9998 (http)
2020-02-17 15:11:11.557  INFO 15286 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-17 15:11:11.558  INFO 15286 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.27]
2020-02-17 15:11:11.635  INFO 15286 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-02-17 15:11:11.635  INFO 15286 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1814 ms
2020-02-17 15:11:11.821  WARN 15286 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'countVersionApplication': Unsatisfied dependency expressed through field 'customSerde'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.stream.binder.kafka.streams.serde.MessageConverterDelegateSerde<com.example.Sensor>' available: expected single matching bean but found 2: messageConverterDelegateSerde,compositeNonNativeSerde
2020-02-17 15:11:11.827  INFO 15286 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-02-17 15:11:11.846  INFO 15286 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-02-17 15:11:11.850 ERROR 15286 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field customSerde in sample.consumer.CountVersionApplication required a single bean, but 2 were found:
        - messageConverterDelegateSerde: defined by method 'messageConverterDelegateSerde' in class path resource [org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderSupportAutoConfiguration.class]
        - compositeNonNativeSerde: defined by method 'compositeNonNativeSerde' in class path resource [org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderSupportAutoConfiguration.class]

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
deepi2003 commented 4 years ago

I am also facing the same issue. Do we have any solution as of now?

BrokenWingsIcarus commented 2 years ago

need help

sobychacko commented 2 years ago

@BrokenWingsIcarus We recently moved the schema registry project to core Spring Cloud Stream: https://github.com/spring-cloud/spring-cloud-stream/tree/main/schema-registry

Here is a sample using this: https://github.com/spring-cloud/spring-cloud-stream/tree/main/samples/spring-cloud-stream-schema-registry-integration

Reference docs here: https://docs.spring.io/spring-cloud-stream/docs/4.0.0-SNAPSHOT/reference/html/spring-cloud-stream-schema-registry.html#spring-cloud-stream-schema-registry-reference

In the 3.x version of Spring Cloud Stream, the schema registry initiative was sort of deprecated, and we are revamping it on 4.0. Please checkout the newly re-instated version of Schema Registry and see if that meets your requirements.