美文网首页Dubbo 源码学习DubboDubbo
dubbo调用时遇到“inconsistent stack he

dubbo调用时遇到“inconsistent stack he

作者: 白花蛇草可乐 | 来源:发表于2019-11-18 14:55 被阅读0次

    坑。坑!坑!!

    一个非常简单的dubbo方法,调用时返回如下错误信息:

    java.lang.RuntimeException: [source error] getPropertyValue (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object; in com.alibaba.dubbo.common.bytecode.Wrapper46: inconsistent stack height -1
      at com.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:301) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:255) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.common.bytecode.Wrapper.makeWrapper(Wrapper.java:237) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:99) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:443) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:356) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:315) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:214) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:120) ~[dubbo-2.5.10.jar:2.0.1]
      at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:49) ~[dubbo-2.5.10.jar:2.0.1]
      ……略……
    Caused by: javassist.CannotCompileException: [source error] getPropertyValue (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object; in com.alibaba.dubbo.common.bytecode.Wrapper46: inconsistent stack height -1
      at javassist.CtNewMethod.make(CtNewMethod.java:79) ~[javassist-3.21.0-GA.jar:?]
      at javassist.CtNewMethod.make(CtNewMethod.java:45) ~[javassist-3.21.0-GA.jar:?]
      at com.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:280) ~[dubbo-2.5.10.jar:2.0.1]
      ... 24 more
    Caused by: javassist.compiler.CompileError: getPropertyValue (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object; in com.alibaba.dubbo.common.bytecode.Wrapper46: inconsistent stack height -1
      at javassist.compiler.Javac.compile(Javac.java:104) ~[javassist-3.21.0-GA.jar:?]
      at javassist.CtNewMethod.make(CtNewMethod.java:74) ~[javassist-3.21.0-GA.jar:?]
      at javassist.CtNewMethod.make(CtNewMethod.java:45) ~[javassist-3.21.0-GA.jar:?]
      at com.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:280) ~[dubbo-2.5.10.jar:2.0.1]
      ... 24 more
    

    中间的分析就不写了,实在是心塞……

    错误原因是这样的:

    dubbo方法名取成了: getTestNum()

    因为方法名取的有问题,dubbo并不认为这是一个需要远程调用的方法,不去做远程调用然后反序列化;而是认为这是一个 property 的普通 get/set 方法,然而找不到叫做 testNum 的 property,就报错了。

    方法名改成 queryTestNum() 或者 getTestNum(参数列表) 均可以正常使用

    相关文章

      网友评论

        本文标题:dubbo调用时遇到“inconsistent stack he

        本文链接:https://www.haomeiwen.com/subject/jvqbictx.html