Skip to content

consul registry: NullPointerException #3923

Closed
@byronzoz

Description

@byronzoz

[description]
simple test consul registry

java: 1.8
os: mac os
dubbo: 2.7.1

[problem]
I use zk as registry center, everything is fine. Now I change the registry to consul.

provider facade definition:

public interface SessionContentFacade {

   public String sayHello(String name);
}

public class SessionContentFacadeImpl implements SessionContentFacade {

    @Override
    public String sayHello(String name) {
        return name + ": hi";
    }
}

<!-- app -->
<dubbo:application name="provider" owner="byronzoz">
	<dubbo:parameter key="qos.enable" value="false" />
</dubbo:application>

<!-- registry -->
<dubbo:registry address="consul://10.100.12.2:8500" />

<!-- service -->
<dubbo:service interface="com.byronzoz.common.service.facade.SessionContentFacade" ref="sessionContentFacade" />

<!-- impl -->
<bean id="sessionContentFacade" class="com.byronzoz.biz.service.impl.SessionContentFacadeImpl" />

The service consumer side:

@Path("/api/v1.0/test")
@Produces({ ContentType.APPLICATION_JSON_UTF_8 })
public interface TestFacade {

    @GET
    @Path("/sayHello")
    public String call(@QueryParam("name") String name);
}

public class TestFacadeImpl implements TestFacade {

    @Autowired
    private SessionContentFacade sessionContentFacade;

    @Override
    public String call(String name) {
        return sessionContentFacade.sayHello(name);
    }
}
<!-- app -->
<dubbo:application name="consumer" owner="byronzoz">
	<dubbo:parameter key="qos.enable" value="false" />
</dubbo:application>

<!-- registry -->
<dubbo:registry address="consul://10.100.12.2:8500" />

<!-- expose rest rpc service -->
<dubbo:protocol name="rest" server="tomcat" port="8099" id="rest_protocol" />

<!-- service -->
<dubbo:service interface="com.byronzoz.common.service.facade.TestFacade" ref="testFacade" protocol="rest_protocol" />

<!-- impl -->
<bean id="testFacade" class="com.byronzoz.biz.service.impl.TestFacadeImpl" />

The service provider side: service started. Provider side uses dubbo as protocol. But consumer side throw NullPointerException as following:

waiting for retry, cause: null, dubbo version: 2.7.1, current host: 3.0.1.176
java.lang.NullPointerException
	at org.apache.dubbo.registry.consul.ConsulRegistry.lambda$convert$3(ConsulRegistry.java:203)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at org.apache.dubbo.registry.consul.ConsulRegistry.convert(ConsulRegistry.java:205)
	at org.apache.dubbo.registry.consul.ConsulRegistry.doSubscribe(ConsulRegistry.java:134)
	at org.apache.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:290)
	at org.apache.dubbo.registry.consul.ConsulRegistry.subscribe(ConsulRegistry.java:118)
	at org.apache.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:157)
	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:386)
	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:367)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:114)
	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:70)
	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:65)
	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:366)
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:305)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:231)
	at org.apache.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:71)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1468)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:249)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:917)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:860)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:775)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.apache.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
	at org.apache.dubbo.container.Main.main(Main.java:89)

[result]
Pls check consul registry implementation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions