nacos启动异常

搭建个新服务,nacos做配置中心,运维帮忙部署时出了几个异常,记录下。

第一个异常:

[ERROR] c.a.n.c.c.impl.ClientWorker.getServerConfig:304 - [fixed-nacos2-xxx.xxx.com_80-tv-dev] [sub-server-error] no right, dataId=tm-xxx-server, group=TM_xxx_GROUP, tenant=tv-dev
[ERROR] c.a.c.n.c.NacosPropertySourceBuilder.loadNacosData:101 - get data from Nacos error,dataId:tm-xxx-server 
com.alibaba.nacos.api.exception.NacosException: <html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Thu Jan 13 15:07:22 CST 2022</div><div>There was an unexpected error (type=Forbidden, status=403).</div><div>authorization failed!</div></body></html>
	at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:306)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:73)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadApplicationConfiguration(NacosPropertySourceLocator.java:141)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:103)

主要是抛出了一个【authorization failed】,检查配置信息。

PS:最开始的两行打印处了[ERROR]

fixed-nacos2-xxx.xxx.com_80-tv-dev
nacos的连接地址

dataId=tm-xxx-server
配置的yml名称
group=TM_xxx_GROUP
组名称
tenant=tv-dev
命名空间namespace

定位发现运维把namespace配错了,导致异常出现。

第二个异常:

ERROR [tm-simba-server,,,] 10 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-nacos2-offline.ikunchi.com_80-mqk-dev] [sub-server-error] no right, dataId=tm-simba-server, group=TM_SIMBA_GROUP, tenant=mqk-dev
[main] ERROR c.a.n.c.c.i.ClientWorker - [getServerConfig,304] - [fixed-nacos2-offline.ikunchi.com_80-mqk-dev] [sub-server-error] no right, dataId=tm-simba-server, group=TM_SIMBA_GROUP, tenant=mqk-dev
 WARN [tm-simba-server,,,] 10 --- [           main] io.sentry.dsn.Dsn                        : *** Couldn't find a suitable DSN, Sentry operations will do nothing! See documentation: https://docs.sentry.io/clients/java/ ***
[main] WARN  io.sentry.dsn.Dsn - [dsnLookup,89] - *** Couldn't find a suitable DSN, Sentry operations will do nothing! See documentation: https://docs.sentry.io/clients/java/ ***
 WARN [tm-simba-server,,,] 10 --- [           main] io.sentry.DefaultSentryClientFactory     : No 'stacktrace.app.packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://docs.sentry.io/clients/java/config/#in-application-stack-frames
[main] WARN  i.s.DefaultSentryClientFactory - [getInAppFrames,524] - No 'stacktrace.app.packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://docs.sentry.io/clients/java/config/#in-application-stack-frames
ERROR [tm-simba-server,,,] 10 --- [           main] c.a.c.n.c.NacosPropertySourceBuilder     : get data from Nacos error,dataId:tm-simba-server 
com.alibaba.nacos.api.exception.NacosException: <html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Tue Jan 11 11:28:39 CST 2022</div><div>There was an unexpected error (type=Forbidden, status=403).</div><div>authorization failed!</div></body></html>
	at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:306)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85)

又抛出了【authorization failed!】,此时namespace已经匹配上了,为啥又报错?很是尴尬,经过复盘提出猜想。最初namespace是“AAA”,项目正常运行后经理过来要求把namespace改成“XXX”。运维更改后项目启动失败,猜测是更改namespace时用户权限分配的有问题。经过一系列修改后启动仍然失败,后来为了彻底验证是不是账号授权问题运维删除了账号和namespace,重新配置了一遍,项目启动成功。

总结:不要随便更改namespace和账号权限,运维在部署服务时自己也要检查一遍运维的配置。上述问题并不是很高深的问题,但是部署环境时稍不注意就会发生。

第三个异常(本地异常):

[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:112 - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:112 - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:112 - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.http.ServerHttpAgent.httpGet:133 - no available server
[main] {"SERVICE":"applicationName_IS_UNDEFINED","X-B3-SpanId":"","X-B3-TraceId":"","X-B3-ParentSpanId":""} [ERROR] c.a.n.c.c.impl.ClientWorker.getServerConfig:279 - [fixed-localhost_8848] [sub-server] get server config exception, dataId=null.properties, group=DEFAULT_GROUP, tenant=
java.net.ConnectException: no available server
	at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpGet(ServerHttpAgent.java:134)
	at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpGet(MetricsHttpAgent.java:51)
	at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:274)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:155)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:98)

显示【connect timed out】,并且dataId、group、tenant都不正常。仔细检查了yml没啥问题,就是项目起不来,无语中。

后来发现是服务启动时nacos对读取yml文件的时机有要求,nacos作为配置中心要连接nacosServer获取服务的配置文件,所以服务启动时nacos的信息要配置在bootstrap.yml中被项目最先加载。

平时写了N行的代码,但也不是天天配置项目,初学nacos的时候也看到过这个点,但上一次看到的时候还是上一次,确实忘记了,挺尬的。

第四个异常:

另外一组的同事封装了下nacos,咱也没看到人家源码,咱也不懂。问题是我们组同事引入封装的依赖后项目运行异常,可怜人被分配到过来解决这个问题。

项目拉下来运行发现nacos源码中有个方法调用的构造方法有问题,构造方法定义的入参是两个,nacos调用该构造方法入参是三个,所以源码报异常了。问题到这这就简单了,上官网看了下nacos各个版本依赖的springCloud,又看了下服务当前依赖的springCloud版本,果然版本冲突。

PS:图是9月份处理这个问题时截得,公司网络有问题GitHub打不开,就这张意思下吧 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]中的日志显示,在启动Spring Boot服务时,服务注册到Nacos时报了500空指针异常。具体的错误信息是"java.lang.NullPointerException"。引用\[2\]中的日志显示,在登录Nacos服务器后,查看nacos.log后台日志时报了"unable to find local peer: 127.0.0.1:8848"的错误。引用\[3\]中的错误信息显示"Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :No DataSource set"。根据这些信息,可以推断出Nacos启动时出现了空指针异常的问题。 空指针异常通常是由于代码中使用了空对象引用而导致的。在这种情况下,可能是Nacos的配置或者依赖出现了问题。首先,可以检查Nacos的配置文件,确保配置正确并且没有缺失。其次,可以检查Nacos的依赖是否正确引入,并且版本是否兼容。另外,还可以尝试重启Nacos服务,以确保问题不是由于服务启动过程中的临时问题引起的。 如果以上方法都没有解决问题,可以尝试查看更详细的错误日志,以获取更多的信息来定位问题所在。可以查看Nacos的官方文档或者社区论坛,寻求帮助和解决方案。 #### 引用[.reference_title] - *1* *2* [解决服务不能注册到 Nacos 报 500 空指针异常](https://blog.csdn.net/sshduanzhijun/article/details/104746550)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [centos linux中使用docker关于nacos启动异常](https://blog.csdn.net/qq_50479320/article/details/129221896)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值