seata异常:io.seata.common.exception.FrameworkException: No available service
参考文章(写得不错):Seata 1.4.0 + nacos配置和使用,超详细_机械广的博客-CSDN博客_seata1.4
1.基础设置:
- 运行seata 实例: seata-samples/nacos at master · seata/seata-samples · GitHub
- nacos版本:1.4.2
- seata-server版本:1.4.2
按照user guide中的account - storage -order的顺序启动,一切正常,nacos中可以看到有三个provider和一个comsumer,并且seata-server这个服务也注册进了nacos。
但是在启动DubboBusinessTester 进行测试的时候,报以下错误:
15:04:16,743 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
15:04:16,743 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [STDOUT]. Did you define it below instead of above in the configuration file?
15:04:16,743 |-ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
15:04:16,743 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:04:16,743 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@224aed64 - Registering current configuration as safe fallback point
Exception in thread "main" io.seata.common.exception.FrameworkException: No available service
at io.seata.core.rpc.netty.AbstractNettyRemotingClient.loadBalance(AbstractNettyRemotingClient.java:265)
at io.seata.core.rpc.netty.AbstractNettyRemotingClient.sendSyncRequest(AbstractNettyRemotingClient.java:141)
at io.seata.tm.DefaultTransactionManager.syncCall(DefaultTransactionManager.java:95)
at io.seata.tm.DefaultTransactionManager.begin(DefaultTransactionManager.java:53)
at io.seata.tm.api.DefaultGlobalTransaction.begin(DefaultGlobalTransaction.java:105)
at io.seata.tm.api.TransactionalTemplate.beginTransaction(TransactionalTemplate.java:215)
at io.seata.tm.api.TransactionalTemplate.execute(TransactionalTemplate.java:122)
at io.seata.spring.annotation.GlobalTransactionalInterceptor.handleGlobalTransaction(GlobalTransactionalInterceptor.java:181)
at io.seata.spring.annotation.GlobalTransactionalInterceptor.invoke(GlobalTransactionalInterceptor.java:150)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at io.seata.samples.nacos.service.impl.BusinessServiceImpl$$EnhancerBySpringCGLIB$$ee303a00.purchase(<generated>)
at io.seata.samples.nacos.starter.DubboBusinessTester.main(DubboBusinessTester.java:39)
2.参考seata常见问题的答案:
这是什么原因呢?是什么造成了这种异常?可以参考seata经典问答:Seata常见问题
Q: Nacos 作为 Seata 配置中心时,项目启动报错找不到服务。如何排查,如何处理?
A: 异常:io.seata.common.exception.FrameworkException: can not register RM,err:can not connect to services-server.
- 查看nacos配置列表,seata配置是否已经导入成功
- 查看nacos服务列表,serverAddr是否已经注册成功
- 检查client端的registry.conf里面的namespace,registry.nacos.namespace和config.nacos.namespace填入nacos的命名空间ID,默认"",server端和client端对应,namespace 为public是nacos的一个保留控件,如果您需要创建自己的namespace,最好不要和public重名,以一个实际业务场景有具体语义的名字来命名
- nacos上服务列表,serverAddr地址对应ip地址应为seata启动指定ip地址,如:sh seata-server.sh -p 8091 -h 122.51.204.197 -m file
- 查看seata/conf/nacos-config.txt 事务分组service.vgroupMapping.trade_group=default配置与项目分组配置名称是否一致
- telnet ip 端口 查看端口是都开放,以及防火墙状态
注:
1.080版本启动指定ip问题,出现异常Exception in thread "main" java.lang.RuntimeException: java.net.BindException: Cannot assign request address,请升级到081以上版本
2.项目使用jdk13,启动出现
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
如环境为sh,替换脚本中最后一段:
exec "$JAVACMD" $JAVA_OPTS -server -Xmx2048m -Xms2048m -Xmn1024m -Xss512k -XX:SurvivorRatio=10 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1024m -XX:-OmitStackTraceInFastThrow -XX:-UseAdaptiveSizePolicy -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="$BASEDIR"/logs/java_heapdump.hprof -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:+
UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -verbose:gc -Dio.netty.leakDetectionLevel=advanced \
-classpath "$CLASSPATH" \
-Dapp.name="seata-server" \
-Dapp.pid="$$" \
-Dapp.repo="$REPO" \
-Dapp.home="$BASEDIR" \
-Dbasedir="$BASEDIR" \
io.seata.server.Server \
"$@"
发现第一条有问题,没有将seata的配置导入nacos:
找了一篇文章:https://blog.csdn.net/qq853632587/article/details/111644295 ,按照里面的步骤,将seata的配置导入了nacos, (也请参考http://seata.io/zh-cn/blog/seata-nacos-analysis.html)
但是发现仍然没有解决问题,怎么办呢?继续看呗
3.尝试其它方式:
参考了以下几篇文章:
- nacos注册服务及集成seata踩坑记录(No available service)_alanzy123的博客-CSDN博客_seata注册nacos失败
- SpringCloud系列之Nacos+Dubbo+Seata应用篇 - 吴码 - 博客园
- 微服务分布式事务解决方案-springboot整合分布式seata1.3.0-阿里云开发者社区
参考上面第一篇文章后,修改访问seata server的客户端seata-all的版本,将其由1.4.2改成1.3.0,问题解决。(如果还不好使,换其它版本试试)
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<!-- <version>${seata.version}</version> -->
<version>1.3.0</version>
</dependency>
另外两篇文章也可以看看。
更多推荐
所有评论(0)