Trouble Using Eureka REST API

363 views
Skip to first unread message

bk...@cyrusinnovation.com

unread,
Mar 10, 2015, 12:12:34 PM3/10/15
to eureka_...@googlegroups.com
Hey Everyone,

Trying to register an application using the REST API and am getting an NPE. Here is the JSON we're sending with the POST request:

{"instance":
{ "name": "ctbserver",
"app": "ctbserver",
"port": "80",
"securePort": "443",
"leaseInfo": {
"evictionDurationInSecs": "1000"
},
"hostname": "XXXX.herokuapp.com",
"status": "STARTING",
"statusPageUrl": "XXXX.herokuapp.com/status",
"healthCheckUrl": "XXXX.herokuapp.com/health",
"dataCenterInfo": {
"name": "MyOwn"
}
}
}

Here's an excerpt from the log:

2015-03-10T15:48:24.353287+00:00 app[web.1]: java.lang.NullPointerException: null
2015-03-10T15:48:24.353289+00:00 app[web.1]: at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
2015-03-10T15:48:24.353291+00:00 app[web.1]: at com.netflix.eureka.InstanceRegistry.register(InstanceRegistry.java:164)
2015-03-10T15:48:24.353296+00:00 app[web.1]: at com.netflix.eureka.PeerAwareInstanceRegistry.register(PeerAwareInstanceRegistry.java:466)
2015-03-10T15:48:24.353298+00:00 app[web.1]: at com.netflix.eureka.PeerAwareInstanceRegistry$$FastClassBySpringCGLIB$$336b8c82.invoke(<generated>)

Appreciate any help or suggestions. Thanks!

Tomasz Bak

unread,
Mar 10, 2015, 2:37:47 PM3/10/15
to eureka_...@googlegroups.com
Which version of eureka server are you running?


--
You received this message because you are subscribed to the Google Groups "eureka_netflix" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eureka_netfli...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

bk...@cyrusinnovation.com

unread,
Mar 10, 2015, 5:30:20 PM3/10/15
to eureka_...@googlegroups.com
Believe it's version 1. It's whichever version comes along with SpringCloud 1.0.0. Thanks in advance for your help!

Tomasz Bak

unread,
Mar 10, 2015, 6:20:42 PM3/10/15
to eureka_...@googlegroups.com
Can you give me exact version? Line numbers from stack trace do not match the latest sources, and I believe you just miss some value in instanceInfo object.

On Tue, Mar 10, 2015 at 2:30 PM, <bk...@cyrusinnovation.com> wrote:
Believe it's version 1. It's whichever version comes along with SpringCloud 1.0.0. Thanks in advance for your help!

dl...@netflix.com

unread,
Mar 11, 2015, 3:54:46 PM3/11/15
to eureka_...@googlegroups.com
Looks like springCloud is using version 1.1.147.

Are you using the standard SpringCloud EurekaInstanceConfigBean or are you adding any additional changes to either the instanceInfo (e.g. in your application.yml) or the DataCenterInfo?

bk...@cyrusinnovation.com

unread,
Mar 13, 2015, 10:27:13 AM3/13/15
to eureka_...@googlegroups.com
We're using the standard InstanceConfigBean, haven't changed anything in the .yml or DataCenterInfo.

Tomasz Bak

unread,
Mar 13, 2015, 11:25:37 AM3/13/15
to eureka_...@googlegroups.com
Looking again in the later code base, I could match this exception to a place where during the registration process InstanceInfo.getId() is called on the client provided object, and used when accessing the internal registry ConcurrentHashMap.
The exception implies the id is null, that shall never happen in AWS deployment, as in AWS this value is derived from AWS metainfo. If you are running out of AWS, than most likely you are using "MyOwn" data center type, which by default provides no attributes, and as an id a host name set on the object is returned. Here is the related code snippet:
class InstanceInfo {
   ...
    /**
     *
     * Returns the unique id of the instance.
     *
     * @return the unique id.
     */
    public String getId() {
        if (dataCenterInfo instanceof UniqueIdentifier) {
            return ((UniqueIdentifier) dataCenterInfo).getId();
        } else {
            return hostName;
        }
    }
}
I suspect you did not set hostname on your InstanceInfo object. The exception thrown here is unfortunately not self explanatory (we will fix that).
/Tomasz

On Fri, Mar 13, 2015 at 7:27 AM, <bk...@cyrusinnovation.com> wrote:
We're using the standard InstanceConfigBean, haven't changed anything in the .yml or DataCenterInfo.

bk...@cyrusinnovation.com

unread,
Mar 13, 2015, 3:07:12 PM3/13/15
to eureka_...@googlegroups.com
Thank you for the response Tomasz! We will give your feedback a try and let you know how it goes.
Reply all
Reply to author
Forward
0 new messages