alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.79k stars 8.3k forks source link

javassist.compiler.CompileError: setSkyWalkingDynamicField(java.lang.Object) #1101

Open YangXueJun opened 4 years ago

YangXueJun commented 4 years ago

Question

I integrate Spring Cloud Alibaba and Skywalking,when one service is exposed to Rest and dubbo at the same time, it will throw a RuntimeException. You can see my issue that is mentioned in skywalking issues by me. (我在整合Spring Cloud Alibaba 和 Skywalking过程中,当一个服务类同时暴露成为一个dubbo服务和Rest服务时,会抛出一个RuntimeException。这个问题我已经在skywalking Issue中提出,你可以看看他们的回答:https://github.com/apache/skywalking/issues/3996)。

code

@RestController
@Service
public class ProviderDemoServiceImpl implements ProviderDemoService {

    @Autowired
    private GoodsStorageMapper goodsStorageMapper;

    /**
     * 描述功能
     * @param helloReqDto
     * @return HelloResDto
     * @author yangxuejun
     * @date 2019/11/26 上午10:48
     **/
    @Override
    public HelloResDto hello(HelloReqDto helloReqDto) {

        log.info(JSON.toJSONString(helloReqDto));

        return new HelloResDto("I'am fine!");
    }
}

error log

java.lang.RuntimeException: [source error] setSkyWalkingDynamicField(java.lang.Object) not found in com.topology.mamaezhan.cloud.pdemo.service.application.service.impl.ProviderDemoServiceImpl
    at org.apache.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:348)
    at org.apache.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:287)
    at org.apache.dubbo.common.bytecode.Wrapper.makeWrapper$original$POGqGkKA(Wrapper.java:261)
    at org.apache.dubbo.common.bytecode.Wrapper.makeWrapper$original$POGqGkKA$accessor$taGwTSLo(Wrapper.java)
    at org.apache.dubbo.common.bytecode.Wrapper$auxiliary$azLLPFgY.call(Unknown Source)
    at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsInter.intercept(StaticMethodsInter.java:86)
    at org.apache.dubbo.common.bytecode.Wrapper.makeWrapper(Wrapper.java)
    at org.apache.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:118)
    at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory.getInvoker(JavassistProxyFactory.java:41)
    at org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.getInvoker(StubProxyFactoryWrapper.java:118)
    at org.apache.dubbo.rpc.ProxyFactory$Adaptive.getInvoker(ProxyFactory$Adaptive.java)
    at org.apache.dubbo.config.ServiceConfig.exportLocal(ServiceConfig.java:641)
    at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:576)
    at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:457)
    at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:415)
    at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:378)
    at org.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:336)
    at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:114)
    at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:60)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
    at com.topology.mamaezhan.cloud.providerdemo.launcher.ProviderDemoLauncher.main(ProviderDemoLauncher.java:21)
Caused by: javassist.CannotCompileException: [source error] setSkyWalkingDynamicField(java.lang.Object) not found in com.topology.mamaezhan.cloud.pdemo.service.application.service.impl.ProviderDemoServiceImpl
    at javassist.CtNewMethod.make(CtNewMethod.java:79)
    at javassist.CtNewMethod.make(CtNewMethod.java:45)
    at org.apache.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:323)
    ... 33 common frames omitted
Caused by: javassist.compiler.CompileError: setSkyWalkingDynamicField(java.lang.Object) not found in com.topology.mamaezhan.cloud.pdemo.service.application.service.impl.ProviderDemoServiceImpl
    at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:749)
    at javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:695)
    at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157)
    at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:330)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
    at javassist.compiler.CodeGen.atIfStmnt(CodeGen.java:398)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:355)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
    at javassist.compiler.CodeGen.atMethodBody(CodeGen.java:292)
    at javassist.compiler.CodeGen.atMethodDecl(CodeGen.java:274)
    at javassist.compiler.ast.MethodDecl.accept(MethodDecl.java:44)
    at javassist.compiler.Javac.compileMethod(Javac.java:169)
    at javassist.compiler.Javac.compile(Javac.java:95)
    at javassist.CtNewMethod.make(CtNewMethod.java:74)
    ... 35 common frames omitted
fangjian0423 commented 4 years ago

could you provide a project that reproduces the issue?

liwm1100 commented 4 years ago

我也遇到相同的问题,怎么解?