问题
I would like to add a node.js server as a microservice application on jhipster-registry. I use eureka-js-client npm package
You can find a node test project "zhudan/node-eureka" on github
// ------------------ 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)
At each refresh of JHipster-registery view of applications i obtain a nullpointerexception
PS : JHipster-registery is starting with ./mvnw command with no changes from your git repo
I provide you complete log of jhipster-registery regitry-logs.txt Regards,
来源:https://stackoverflow.com/questions/45170555/jhipster-registry-and-nodejs-eureka-js-client-nullpointerexception