Skip to content

NullPointerException when start provider #5216

@luyuanwan

Description

@luyuanwan
  • [*] I have searched the issues of this repository and believe that this is not a duplicate.
  • [*] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.5-SNAPSHOT
  • Dubbo branch: master
  • Operating System version: macOS Catalina
  • Java version: jdk-11.0.5

Steps to reproduce this issue

  1. start zookeeper in localhost and port is 2181
  2. write provider-side code
  3. start provider, the provider-side code looks like this
public class Application {

	private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");

	public static void main(String[] args) throws Exception {
		ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
		service.setApplication(new ApplicationConfig("first-dubbo-provider"));
		service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
		service.setInterface(DemoService.class);
		service.setRef(new DemoServiceImpl());
		service.export();

		System.out.println("dubbo service started");
		new CountDownLatch(1).await();
	}
}

Actual Result

But I got an exception.

Exception in thread "main" java.lang.NullPointerException
	at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$useRegistryForConfigIfNecessary$7(AbstractInterfaceConfig.java:628)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at org.apache.dubbo.config.AbstractInterfaceConfig.lambda$useRegistryForConfigIfNecessary$8(AbstractInterfaceConfig.java:620)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at org.apache.dubbo.config.AbstractInterfaceConfig.useRegistryForConfigIfNecessary(AbstractInterfaceConfig.java:618)
	at org.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:208)
	at org.apache.dubbo.config.ServiceConfig.checkAndUpdateSubConfigs(ServiceConfig.java:303)
	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:370)
	at com.example.studydubboProvider.Application.main(Application.java:22)

Is this an issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions