我正在尝试配置ServletInitializer以在具有WAR打包功能的tomcat主机中运行Spring Stream Aggreagate Application。 父应用配置为...

@SpringBootApplication
public class MyAggregateApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        AggregateApplication aggregateApp = new AggregateApplicationBuilder()
                .from(MySource.class)
                .via(MyProcessor.class)
                .to(LogSink.class).build();
        return application.sources(aggregateApp);
    }

    public static void main(String[] args) {
        new AggregateApplicationBuilder()
                .from(MySource.class)
                .via(MyProcessor.class)
                .to(LogSink.class)
                .run(args);
    }
}

它可以作为独立的jar运行,但是,当部署到Tomcat服务器时,ServletInitializer配置挂钩不能接受application.sources(aggregateApp)的配置方法返回,因为错误提示...

java.lang.IllegalArgumentException: Invalid source type class org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:146) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:635) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:355) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:301) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169) [spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [catalina.jar:8.5.20]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.20]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) [catalina.jar:8.5.20]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) [catalina.jar:8.5.20]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.20]
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988) [catalina.jar:8.5.20]
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860) [catalina.jar:8.5.20]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_65]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_65]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]

15-Aug-2017 23:21:17.315 SEVERE [localhost-startStop-2] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Invalid source type class org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:146)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:635)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:355)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:301)
    at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
    at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
    at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 10 more

15-Aug-2017 23:21:17.316 SEVERE [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [tomcat/webapps/ROOT.war]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

并尝试使用AppClass像...

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(MyAggregateApplication.class);
}

不想将应用程序配置为AggregateApplication,不自动配置内部消息代理,并导致此错误...

Failed to instantiate [org.springframework.cloud.stream.binder.BinderTypeRegistry]: Circular reference involving containing bean 'org.springframework.cloud.stream.config.BinderFactoryConfiguration' - consider declaring the factory method as static for independence from its containing instance. Factory method 'binderTypeRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot create binder factory, no `META-INF/spring.binders` resources found on the classpath
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169) [spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [catalina.jar:8.5.20]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.20]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) [catalina.jar:8.5.20]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) [catalina.jar:8.5.20]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.20]
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988) [catalina.jar:8.5.20]
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860) [catalina.jar:8.5.20]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_65]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_65]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]

关于在ServletInitalizer中连接AggregateApplication或禁用binderRegistry bean以忽略丢失的绑定器的任何建议? 添加RabbitMQ或Kafka绑定程序会导致Processor应用绑定到这些代理。

#1楼 票数:1

application.sources(aggregateApp)

由于AggregateApplicationBuilder并非有效的SpringApplicationBuilder来源,因此上述似乎不是正确的做法,因为您只能将ClassPackageResourceCharSequence有效类型作为来源。

#2楼 票数:0 已采纳

我可以通过向聚合堆栈提供run()方法来使其运行,该方法返回ConfigurableApplicationContext,该方法可以作为源。 我还不得不使用web(false)禁用web,因为嵌入式tomcat似乎仍然想启动...

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(new AggregateApplicationBuilder()
            .web(false)
            .from(MySource.class)
            .via(MyProcessor.class)
            .to(LogSink.class)
            .run(new String[] {}));
}

  ask by Alan Schultz translate from so

未解决问题?本站智能推荐:

4回复

Dispatcher没有频道订阅者-spring-cloud-stream-kafka

升级到 Spring Boot 2、Reactor 3.5、kafka-binder 2.0.0 RELEASE 和 kafka-client 1.0.1 后,其中一个模块不起作用。 我花了 5 天时间完成并阅读了所有相关主题,但找不到这种行为的原因。 主要类: 配置标记: 通道接口: 还有 Adm
1回复

如果spring-cloud-stream在类路径上,则spring-boot自动配置正在寻找默认绑定器

我正在开发一个 spring-boot 多模块应用程序,我们正在创建一个自定义的 fat jar 来绑定所有第三方依赖项。 Spring cloud stream也是这个肥罐的一部分。 我们的应用程序在spring-cloud-stream版本2.1.3.RELEASE ( spring-boot
1回复

如何从基于spring-cloud-stream-stream的微服务中调用python脚本

我正在考虑使用spring-cloud-stream以RabbitMQ作为代理来构建消息驱动的微服务应用程序。 我看到spring-cloud-stream建立在Spring-Integration(SI)的基础上,SI提供了spring-integration-scripting来执行py
2回复

如何为spring-cloud-stream-app-starters项目创建自定义源应用程序

我想创建一个Web套接字源(用于spring-cloud-stream-app-starters ),该源目前在git hub上不可用。 我浏览了一些可用的资源,但有些困惑,可能是因为我对框架不熟悉。 我是否可以使用Source binding创建一个Spring Boot应用程序,并以
1回复

SpringCloud/Stream/SpringBoot的依赖关系管理和发布培训

这可能是一个非常基本的问题,但是我正在努力查看Spring Boot 2 Mx,Spring Cloud Finchley.x和Spring Cloud Stream Elmhurst.x之间的关系。 是否有任何文档/自述文件解释所有这些版本如何链接在一起? 我有一个需要以下depende
1回复

何时使用org.springframework.context.event.EventListener和org.springframework.cloud.stream.annotation.StreamListener

我正在尝试从spring cloud中学习事件驱动/消息驱动的概念,我遇到了两个注释@EventListener和@StreamListener。 有人可以指导我了解这两者之间的基本区别吗? TIA。
1回复

如何在Spring启动应用程序中配置KafKaBinderHealthIndicator

我正在尝试在spring boot app中为kafka添加运行状况指示器,但状态不会出现在/ health端点上。 我也可以毫无问题地添加其他健康指标。 我是否需要一些特殊配置才能使用spring-cloud-stream-binder-kafka中实现的KafkaBinderHealt
1回复

无法使用spring云流kafka发送自定义标头

我有两个用 Java 编写的微服务,使用 Spring Boot。 我使用 Kafka,通过 Spring Cloud Stream Kafka,在它们之间发送消息。 我需要发送一个自定义标头,但直到现在还没有成功。 我已经阅读并尝试了我在互联网和 Spring Cloud Stream 文