按照網友的這篇文章,我使用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;
}
uj5u.com熱心網友回復:
有訊息嗎 我也遇到了uj5u.com熱心網友回復:
。。。。。。。。。。。。。。沒人來結貼了嗎?uj5u.com熱心網友回復:
最后怎么解決的?我現在也遇到這個問題了轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/77603.html
標籤:Java EE
