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

JHIPSTER Registry and NODEJS eureka-js-client NullPointerException #165

Closed
awattez opened this issue Jul 18, 2017 · 6 comments
Closed

JHIPSTER Registry and NODEJS eureka-js-client NullPointerException #165

awattez opened this issue Jul 18, 2017 · 6 comments

Comments

@awattez
Copy link

awattez commented Jul 18, 2017

Hi,
I would like to add a node.js server as a microservice application on jhipster-registry.
I use https://www.npmjs.com/package/eureka-js-client

You can find a node test project on https://github.com/zhudan/node-eureka

// ------------------ Eureka Config --------------------------------------------
var Eureka = require("eureka-js-client").Eureka;

var client = new Eureka({
    filename: 'eureka-client',
    cwd: __dirname
});
client.logger.level('debug');
client.start(function(error){
    console.log(error || 'complete');
});


// ------------------ Server Config --------------------------------------------
var server = app.listen(9999, function () {
    var host = server.address().address;
    var port = server.address().port;
    console.log('Listening at http://%s:%s', host, port);
});

I change the eureka-client.yml in order to work with jhipster-registery.

eureka:
  heartbeatInterval: 10
  maxRetries: 10
  requestRetryDelay: 60
  registryFetchInterval: 10
  host: 'admin:admin@localhost'
  port: 8761
  servicePath: '/eureka/apps'

instance:
  instanceId: "node-euraka"
  app: 'node-eureka'
  hostName: '127.0.0.1'
  #ipAddr: '192.168.10.145'
  statusPageUrl: 'http://127.0.0.1:9999'
  port:
      '$': 9999
      '@enabled': 'true'
  vipAddress: 'node-eureka'
  dataCenterInfo:
      '@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo'
      name: 'MyOwn'

It's working well i have a complete register and heartbeat working well

$ node app
Listening at http://:::9999
registered with eureka:  node-eureka/node-euraka
retrieved registry successfully
complete
eureka heartbeat success
retrieved registry successfully
eureka heartbeat success
retrieved registry successfully
eureka heartbeat success
retrieved registry successfully

But after that on jhipster-registry i obtain a nullpointerexception.

2017-07-18 10:46:46.452 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect        : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-07-18 10:46:46.454 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect        : Exit: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with result = null
2017-07-18 10:46:46.597  INFO 13124 --- [  XNIO-2 task-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2017-07-18 10:46:46.597  INFO 13124 --- [  XNIO-2 task-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2017-07-18 10:46:46.597  INFO 13124 --- [  XNIO-2 task-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2017-07-18 10:46:46.597  INFO 13124 --- [  XNIO-2 task-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2017-07-18 10:46:51.458 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect        : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-07-18 10:46:51.460 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.service.ZuulUpdaterService       : Checking instance node-euraka - null
2017-07-18 10:46:51.467 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.service.ZuulUpdaterService       : Adding instance 'node-euraka' with URL: null
2017-07-18 10:46:51.489  INFO 13124 --- [pool-4-thread-1] i.g.j.r.service.ZuulUpdaterService       : Zuul routes have changed - refreshing the configuration
2017-07-18 10:46:51.491 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect        : Exit: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with result = null
2017-07-18 10:46:56.492 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect        : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-07-18 10:46:56.494 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.service.ZuulUpdaterService       : Checking instance node-euraka - null
2017-07-18 10:46:56.494 DEBUG 13124 --- [pool-4-thread-1] i.g.j.r.service.ZuulUpdaterService       : Instance 'node-euraka' already registered
2017-07-18 10:46:56.496 ERROR 13124 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect        : Exception in io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with cause = 'NULL' and exception = 'null'

java.lang.NullPointerException: null
        at io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes(ZuulUpdaterService.java:65)

If i stop my node.js it still remains inside the "instances" view during a long time something like 5 min and at each refresh i obtain a nullpointerexception

PS : JHipster-registery is starting with ./mvnw command with no changes from your git repo

I provide you the complete log of jhipster-registery
regitry-logs.txt
Regards,

@PierreBesson
Copy link
Contributor

PierreBesson commented Jul 18, 2017

@blurk Currently the JHipster Registry suppose that the apps registered to it are JHipster apps or at least spring boot apps hence why you have weird errors.

To explain, in addition to serving as a registry, the JHipster Registry also exposes all registered instances through a Zuul proxy.This is done so that you can access your microservices management endpoints (the metrics and log screens).
The ZuulUpdaterService is a hack to setup separate Zuul routes for each instances rather than load balancing between instances of the same service.

I suggest that we devise on an Eureka service metadata (proxyOnRegistry) that you can add to instances that you don't want to be picked up by the ZuulUpdaterService (PierreBesson@0c19194). For example, for a spring boot app.

eureka:
    instance:
        metadata-map:
            proxyOnRegistry: false

Sorry I don't know how to do this with EurekaJS

@deepu105
Copy link
Member

This ticket has been closed as the guidelines are not followed.

Tickets must follow our Guidelines, as mentioned in:

  1. our Readme file on the front page of the project,
  2. the "create a new ticket" page and
  3. our Help page

We have also created a template on the "create a new ticket" page to help you follow those guidelines.

Open a new issue with proper details or update this issue with all details and request to reopen.
Issues opened without proper details will be closed without explanation.

If you have a question please use Stack Overflow for that. Tag the question with jhipster and someone will help you out there.

This helps us to keep our issue tracker clean. Also, Stack Overflow will give your query a larger audience.

@shumybest
Copy link

we met the same problem here, any idea how to fix? (registry 4.1.1 + nodejs eureka client)

Full of NullPointerException:
image

@PierreBesson
Copy link
Contributor

@leratc Those are just debug logs ! Moreover please open a proper issue if you have a bug.

@ghost
Copy link

ghost commented Oct 5, 2020

i solved this NullPointerException problem by adding "homePageUrl" in instance object
in my case :

       instance: {
            hostName: ip.address(),
            instanceId: `${appName}:${serviceID}`,
            vipAddress: `${appName}`,
            app: `${appName.toUpperCase()}`,
            ipAddr: ip.address(),
            status: `UP`,
            port: {
                $: port,
                "@enabled": true
            },
            homePageUrl: `http://${ip.address()}:${port}/`,
            dataCenterInfo: {
                "@class": `com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo`,
                name: `MyOwn`
            }
        } 

@PierreBesson
Copy link
Contributor

@OmidPoorali Can you submit your change as pull request if it fixes an issue for you. We will gladly merge it.

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