Apache Curator NPE on serviceProvider.start()

77
February 13, 2018, at 4:37 PM

I'm using Apache Curator discovery version 4.0.0 and getting this NPE on ConcurrentHashMap.putVal() on starting the service provider for getting a service instance. (kind of like this question but not on JsonInstanceSerializer).

java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011) ~[?:1.8.0_112]
at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1535) ~[?:1.8.0_112]
at org.apache.curator.x.discovery.details.ServiceCacheImpl.addInstance(ServiceCacheImpl.java:196) ~[curator-x-discovery-4.0.0.jar:?]
at org.apache.curator.x.discovery.details.ServiceCacheImpl.start(ServiceCacheImpl.java:96) ~[curator-x-discovery-4.0.0.jar:?]
at org.apache.curator.x.discovery.details.ServiceProviderImpl.start(ServiceProviderImpl.java:75) ~[curator-x-discovery-4.0.0.jar:?]

My code looks like this.

client = CuratorFrameworkFactory.newClient("localhost:2181", new  ExponentialBackoffRetry(1000, 3));
client.start();
serviceDiscovery = ServiceDiscoveryBuilder.builder(ServiceRecord.class).client(client).basePath("/discovery/services/").serializer(serializer).build();
serviceDiscovery.start();
serviceProvider = serviceDiscovery.serviceProviderBuilder().serviceName(serviceName).build();
serviceProvider.start();
READ ALSO
Is A New Object Instantiated Every Time This Loop Runs?

Is A New Object Instantiated Every Time This Loop Runs?

I was taking a Java test today and I got this weird question and I feel like I am right, but some of my classmates are saying another answer is rightThere was a basic class, a default constructor that initialized the instances, and some methods

49
Notification in background

Notification in background

When I open the app and send notification from the FireBase console , the onMessageReceived works fineThe app has its small icon , Notification sound ,etc

82
How to display cards in a Card Game in Java and have them clickable for selection?

How to display cards in a Card Game in Java and have them clickable for selection?

I am programming a game of cards in Java, and everything is going well, but I have come up with a problem regarding the user interfaceThere are 4 players (1 Human 3 AI) and 54 cards

65