使用LCN解决分布式事务报错 tx-manager not connected

wangchenggong1988 2019-01-15 11:07:35
按照网友的这篇文章,我使用springCloud搭建了一个demo
https://segmentfault.com/a/1190000016718525?utm_source=tag-newest

整合LCN之前,在一个本地事务中使用feign调用了其他服务,分布式事务不生效
整合LCN之后,Eureka注册中心、tx_manager以及事务的发起方、参与方都可以正常启动,但是在跑测试类要测试分布式事务时,报以下错误,


java.lang.reflect.UndeclaredThrowableException
at com.tx.pay.service.impl.PayServiceImpl$$EnhancerBySpringCGLIB$$84edcd5c.updatePaymentInfo(<generated>)
at com.tx.pay.service.PayServiceTest.updatePaymentInfo(PayServiceTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.Exception: tx-manager not connected ,please check tx-manager server
at com.codingapi.tx.aop.service.impl.TransactionServerFactoryServiceImpl.createTransactionServer(TransactionServerFactoryServiceImpl.java:52)
at com.codingapi.tx.aop.service.impl.AspectBeforeServiceImpl.around(AspectBeforeServiceImpl.java:50)
at com.codingapi.tx.springcloud.interceptor.TxManagerInterceptor.around(TxManagerInterceptor.java:30)
at com.codingapi.tx.springcloud.interceptor.TransactionAspect.transactionRunning(TransactionAspect.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
... 30 more



跟了一下代码,是TransactionServerFactoryServiceImpl的createTransactionServer方法报的错,好像是说netty服务的状态不正常,我也不确定是到底是什么引起的问题,请使用过LCN的大咖指正一下,谢谢
public TransactionServer createTransactionServer(TxTransactionInfo info) throws Throwable {
if (info.getTransaction() != null && info.getTransaction().isStart() && info.getTxTransactionLocal() == null && StringUtils.isEmpty(info.getTxGroupId())) {
if (this.nettyService.checkState()) {
return this.txStartTransactionServer;
} else {
throw new Exception("tx-manager not connected ,please check tx-manager server ");
}
} else if (info.getTxTransactionLocal() == null && !StringUtils.isNotEmpty(info.getTxGroupId())) {
return this.txDefaultTransactionServer;
}
...全文
1638 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
changingshow 2020-11-19
  • 打赏
  • 举报
回复
我也遇到一样得问题了,太他妈狗血了,问题得原因竟然是 麦卡菲 打开的防火墙拦住了某个端口。全是本地之间访问竟然也能拦住,想了半天才想到可能是防火墙得原因。之前还怀疑端口占用,后来才发现是防火墙。关了就好了。结帖把
weixin_42410385 2020-05-06
  • 打赏
  • 举报
回复
最后怎么解决的?我现在也遇到这个问题了
Tim Gong 2019-07-11
  • 打赏
  • 举报
回复
。。。。。。。。。。。。。。没人来结贴了吗?
u011567033 2019-01-24
  • 打赏
  • 举报
回复
有消息吗 我也遇到了

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧