Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No registry config found or it's not a valid config if registry configured by xml with placeholder #646

Closed
mooseen opened this issue Jan 2, 2020 · 3 comments
Assignees
Milestone

Comments

@mooseen
Copy link

mooseen commented Jan 2, 2020

When configure dubbo service or reference bean by xml, the placeholder will not be replaced by user defined properties. if registry config not configured by dubbo.registries.<registry id> or has no default service registry config, it will throw an exception:

Caused by: java.lang.IllegalStateException: No registry config found or it's not a valid config! The registry config is: <dubbo:registry valid="false" id="registry2" prefix="dubbo.registries." />
	at org.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:177)
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:306)
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:266)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:151)
	at org.apache.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:68)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171)
	... 88 more

If we have default registry config (dubbo.registry.xxx), the reference bean defined in xml will using the default registry config even though we have configured registry in xml. if there is no default resgistry config, but configured by dubbo.registries.<registry id>,reference bean will using registry config defined by dubbo.registries if registry id was the same.

In both cases, the registry config defined in xml are not going to work and ignored by dubbo.

Following configuration can reproduce these exception described above.

  • Dubbo: 2.7.5
  • Dubbo Spring Boot : 2.7.5
  • Spring Boot : 2.2.2.RELEASE

case 1

This config will cause No registry config found or it's not a valid config.

application.properties

dubbo.application.id=demo
dubbo.application.name=demo

# true or false has no effect
#dubbo.config.multiple=true

dubbo.registries.registry1.id=registry1
dubbo.registries.registry1.address=zookeeper://localhost:2181
dubbo.registries.registry1.file=/Users/test/dubbo/registry/registry1

# this config is not working
dubbo.demo.registry=zookeeper://localhost:2181
dubbo.registry.file.path=/Users/test/dubbo/registry/registry2

biz-consumer.xml

    <dubbo:registry id="registry2" address="${dubbo.demo.registry}" file="${dubbo.registry.file.path}" protocol="dubbo" version="1.0.0"/>
    <dubbo:reference id="demoService2" registry="registry2" interface="io.test.dubbo.demo.api.DemoService" protocol="dubbo" version="1.0.0" check="false"/>
    <bean id="barService" class="io.test.dubbo.demo.consumer.client.BarServiceImpl">
        <property name="demoService"  ref="demoService2"/>
    </bean>

case 2

This config will cause reference bean using default registry config even if we define it in XML.
application.properties

dubbo.application.id=demo
dubbo.application.name=demo

# default resgistry
# reference bean will use default registry config even if registry id are different.
dubbo.registry.id=registry1
dubbo.registry.address=zookeeper://localhost:2181
dubbo.registry.file=/Users/test/dubbo/registry/default

# this configuration is not going to work
dubbo.demo.registry=zookeeper://localhost:2181
dubbo.registry.file.path=/Users/test/dubbo/registry/registry2

biz-consumer.xml

    <dubbo:registry id="registry2" address="${dubbo.demo.registry}" file="${dubbo.registry.file.path}" protocol="dubbo" version="1.0.0"/>
    <dubbo:reference id="demoService2" registry="registry2" interface="io.test.dubbo.demo.api.DemoService" protocol="dubbo" version="1.0.0" check="false"/>
    <bean id="barService" class="io.test.dubbo.demo.consumer.client.BarServiceImpl">
        <property name="demoService"  ref="demoService2"/>
    </bean>

case 3

This config will cause reference bean using registry defined by dubbo.resgisties.xxx

application.properties

dubbo.application.id=demo
dubbo.application.name=demo

dubbo.config.multiple=true

# registry 1 config
dubbo.registries.registry1.id=registry1
dubbo.registries.registry1.address=zookeeper://localhost:2181
dubbo.registries.registry1.file=/Users/test/dubbo/registry/registry1

# registry 2 config
# reference bean defined in xml will use this registry as registry id are the same
dubbo.registries.registry2.id=registry2
dubbo.registries.registry2.address=zookeeper://localhost:2181
dubbo.registries.registry2.file=/Users/test/dubbo/registry/registry2

# this config is still not going to work
dubbo.demo.registry=zookeeper://localhost:2181
dubbo.registry.file.path=/Users/test/dubbo/registry/registry2_xml

biz-consumer.xml

    <dubbo:registry id="registry2" address="${dubbo.demo.registry}" file="${dubbo.registry.file.path}" protocol="dubbo" version="1.0.0"/>
    <dubbo:reference id="demoService2" registry="registry2" interface="io.test.dubbo.demo.api.DemoService" protocol="dubbo" version="1.0.0" check="false"/>
    <bean id="barService" class="io.test.dubbo.demo.consumer.client.BarServiceImpl">
        <property name="demoService"  ref="demoService2"/>
    </bean>
@mooseen mooseen changed the title No registry config found or it's not a valid config! The registry config is: <dubbo:registry valid="false" id="registry2" prefix="dubbo.registries." /> No registry config found or it's not a valid config if registry configured by xml with placeholder Jan 2, 2020
@fujinjun
Copy link

在使用apollo注册中心的时候,也会有该问题,我们是consumer.xml中只包含dubbo:reference,其它的配置用apollo加载,会报同样的错,2.7.5也不行

@mercyblitz
Copy link
Contributor

Please trace this issue: apache/dubbo#6036

@Onebyte1943
Copy link

You can solve this problem by using @DubboReference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants