You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class GlobalTransactionTestController {
@GetMapping("/testTcc")
@GlobalTransactional
public ResultGeneralModel<Boolean> testTcc() {
log.info("测试tcc事务务");
tccTestService.prepare(null,123);
int i = 1/0;
return ResultGeneralModel.newSuccess(Boolean.TRUE);
}
}
@Component
@Slf4j
public class TccTestServiceImpl implements TccTestService {
@Override
public void prepare(BusinessActionContext actionContext, int a) {
//一些访问db的动作,省略了,非常简单
log.info("prepare 被调用");
}
@Override
public void commit(BusinessActionContext actionContext) {
log.info("commit 被调用");
}
@Override
public void rollback(BusinessActionContext actionContext) {
log.info("rollback 被调用");
}
}
启动正常,tcc resource注册成功:
INFO org.apache.seata.core.rpc.netty.RmNettyRemotingClient [main] [] [] will register resourceId:TccTestBean
代码执行后报错,报错日志:
2024-12-04 20:56:12.615 ERROR[http-nio-8080-exec-1] [] [] java.lang.NoSuchMethodException: org.springframework.aop.SpringProxy.prepare(org.apache.seata.rm.tcc.api.BusinessActionContext, int)
java.lang.RuntimeException: java.lang.NoSuchMethodException: org.springframework.aop.SpringProxy.prepare(org.apache.seata.rm.tcc.api.BusinessActionContext, int)
at org.apache.seata.rm.tcc.interceptor.TccActionInterceptorHandler.lambda$parseAnnotation$0(TccActionInterceptorHandler.java:118)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at org.apache.seata.rm.tcc.interceptor.TccActionInterceptorHandler.parseAnnotation(TccActionInterceptorHandler.java:103)
at org.apache.seata.rm.tcc.interceptor.TccActionInterceptorHandler.doInvoke(TccActionInterceptorHandler.java:71)
at org.apache.seata.integration.tx.api.interceptor.handler.AbstractProxyInvocationHandler.invoke(AbstractProxyInvocationHandler.java:43)
at org.apache.seata.spring.annotation.AdapterSpringSeataInterceptor.invoke(AdapterSpringSeataInterceptor.java:44)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at xxx.TccTestServiceImpl$$EnhancerBySpringCGLIB$$953891f3.prepare(<generated>)
at xxxxx.seata.GlobalTransactionTestController.testTcc(GlobalTransactionTestController.java:77)
at xxxxx.seata.GlobalTransactionTestController$$FastClassBySpringCGLIB$$14f5a059.invoke(<generated>)
一、相关组件版本
二、问题描述
业务想接入改造成TCC,所以先用一个简单的例子验证一下特性,发现一直达不到效果。
1.tcc相关注解在接口
代码如下:
启动正常,tcc resource注册成功:
代码执行后报错,报错日志:
debug定位了一下报错的地方,这里拿到的接口是SpringProxy,八成是spring代理的,这个接口里肯定是没有的preapre
org.apache.seata.rm.tcc.interceptor.TccActionInterceptorHandler#parseAnnotation
2.tcc相关注解在实现类
看了和tcc使用的相关issue,怀疑是注解的位置导致的,因此我将注解移动到了实现类中,
启动后,虽然tm 和rm注册成功. 但是并没有看到tcc resource注册成功的这条日志:
代码执行后,确实返回了/ by zero异常,但是cacnel方法并没有被回调。
甚至isLocalTCC都没有命中:
以上,希望能得到帮助,多谢!
The text was updated successfully, but these errors were encountered: