【问题标题】:Spring XD - Could not resolve placeholder 'xd.module.sequence'Spring XD - 无法解析占位符“xd.module.sequence”
【发布时间】:2017-02-20 21:47:56
【问题描述】:

我正在处理类似于以下帖子的问题:

Spring -XD Stream deployment failure

issue in spring xd cluster when deploying my module

另外,看到一张 JIRA 票被打开了: https://jira.spring.io/browse/XD-3727

我使用自定义转换器模块创建了一个基本流:stream create test-stream --definition "file | enricher | log" --deploy 在本地,运行单节点时,我的 jar 上传并成功创建了流。但是,在分布式模式下运行时,流会失败:

2017-02-20T22:40:11+0000 1.3.0.RELEASE WARN 61699 DeploymentsPathChildrenCache-0 annotation.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'objectNameProperties' defined in null: Could not resolve placeholder 'xd.module.sequence' in string value "${xd.module.sequence}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'xd.module.sequence' in string value "${xd.module.sequence}"
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:222) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:86) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:166) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:674) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:519) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE]
    at org.springframework.xd.module.core.SimpleModule.initialize(SimpleModule.java:213) [spring-xd-module-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.xd.dirt.module.ModuleDeployer.doDeploy(ModuleDeployer.java:217) [spring-xd-dirt-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.xd.dirt.module.ModuleDeployer.deploy(ModuleDeployer.java:200) [spring-xd-dirt-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.xd.dirt.server.container.DeploymentListener.deployModule(DeploymentListener.java:365) [spring-xd-dirt-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.xd.dirt.server.container.DeploymentListener.deployStreamModule(DeploymentListener.java:334) [spring-xd-dirt-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.xd.dirt.server.container.DeploymentListener.onChildAdded(DeploymentListener.java:181) [spring-xd-dirt-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.xd.dirt.server.container.DeploymentListener.childEvent(DeploymentListener.java:149) [spring-xd-dirt-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:509) [curator-recipes-2.6.0.jar:na]
    at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:503) [curator-recipes-2.6.0.jar:na]
    at org.apache.curator.framework.listen.ListenerContainer$1.run(ListenerContainer.java:92) [curator-framework-2.6.0.jar:na]
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297) [guava-16.0.1.jar:na]
    at org.apache.curator.framework.listen.ListenerContainer.forEach(ListenerContainer.java:83) [curator-framework-2.6.0.jar:na]
    at org.apache.curator.framework.recipes.cache.PathChildrenCache.callListeners(PathChildrenCache.java:500) [curator-recipes-2.6.0.jar:na]
    at org.apache.curator.framework.recipes.cache.EventOperation.invoke(EventOperation.java:35) [curator-recipes-2.6.0.jar:na]
    at org.apache.curator.framework.recipes.cache.PathChildrenCache$10.run(PathChildrenCache.java:762) [curator-recipes-2.6.0.jar:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_51]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_51]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_51]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_51]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'xd.module.sequence' in string value "${xd.module.sequence}"
           at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174) ~[spring-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:258) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitMap(BeanDefinitionVisitor.java:262) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:198) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:208) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
           ... 31 common frames omitted

在日志中,我看到了这个:

2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [zk-properties]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [commandLineArgs]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [systemProperties]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [systemEnvironment]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [random]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [applicationConfig: [classpath:/application.yml]#container]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [applicationConfig: [file:/opt/pivotal/spring-xd-1.3.0.RELEASE/xd/config//servers.yml]]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [applicationConfig: [file:./config/servers.yml]]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [applicationConfig: [classpath:/application.yml]]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.default' in [applicationConfig: [classpath:/servers.yml]]
2017-02-20T16:02:52+0000 1.3.0.RELEASE DEBUG 25853 DeploymentsPathChildrenCache-0 env.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.default' in any property source. Returning [null]

我尝试在 application.yml 中设置 xd.module.sequence = default,它位于我模块的类路径中,因为日志显示:Searching for key 'spring.profiles.default' in [applicationConfig: [classpath:/application.yml]]。但是,抛出了相同的异常。谁能提供有关如何解决此问题的见解?

【问题讨论】:

  • 哦,我看到你提到了 JIRA——这简直太奇怪了;容器显然有问题。我担心您需要在该容器上运行调试器以找出插件未填充该属性的原因。我们一直无法重现此问题。
  • 您使用的是什么版本的 XD?
  • 这是版本 1.3.0.RELEASE
  • 我刚刚在我的应用程序上下文中删除了一个导入,它定义了一个 jpa 存储库和成功部署的流。所以,不知何故,这个导入似乎导致了这个
  • 每个插件注册的属性被加载到一个属性源中。对于xd.module.sequence,你有没有看到类似的东西? Searching for key 'initialDelay' in [properties-2] Searching for key 'initialDelay' in [properties-1] Searching for key 'initialDelay' in [properties-0]插件注册的每个属性源都有一个名称properties-n

标签: spring-xd


【解决方案1】:

这充其量是一种解决方法,但是,如果您不需要 Spring Integration MBean,则可以将 mbean-exporters.xml 替换为没有 <int-jmx:mbean-exporter/> 和相关 bean 的 MBean。

This answer 展示了如何用自定义配置文件替换该配置文件。

或者您可以在 servers.yml 中完全禁用 JMX。

如果确实需要 MBean,则必须为 sequence 属性提供唯一值。可能是递增的AtomicInteger<bean/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    • 2018-02-20
    • 2017-05-01
    • 1970-01-01
    • 2019-01-12
    • 2020-10-05
    • 2017-08-17
    相关资源
    最近更新 更多