我们都知道,Dobbo 的 telnet 工具可以用来调试服务接口。
今天遇到一个特殊情况,代码 ItemProductQuery 类在 ItemProductService 接口中,属于内部类。
public interface ItemProductService {
public static class ItemProductQuery extends BasePageQuery {
private int offset = 0;
private int rows = 10;
private List<String> artisanIdList;
private List<Integer> inStatus;//状态集
...
}
}调用telnet测试,出现类找不到异常,这就很奇怪了
dubbo> invoke ItemProductService.getByItemProductQuery({"class":"com.helijia.item.api.service.ItemProductService.ItemProductQuery","artisanId":"11150a7f733942168960d85e80643c22","rows": 10000,"offset": 0,"isDel": 0})
Not found class com.helijia.item.api.service.ItemProductService.ItemProductQuery, cause: com.helijia.item.api.service.ItemProductService.ItemProductQuery类的全路径是正常的,可是为什么就是找不到类呢?
仔细想想应该是内部类被JVM编译后,路径有变动,我们知道内部类会被编译成一个新的class文件,那么我只要找出这个正确的jvm路径,问题应该就迎刃而解了。
用arthas来分析,结果如下
[arthas@637]$ sm *ItemProductQuery com.xxx.item.api.service.ItemProductService$ItemProductQuery <init>()V com.xx.item.api.service.ItemProductService$ItemProductQuery getName()Ljava/lang/String; com.xx.item.api.service.ItemProductService$ItemProductQuery setName(Ljava/lang/String;)V ....
看得出,路径中间一个 $ 符号,就是这个原因了。
修改后,执行成功
dubbo> invoke ItemProductService.getByItemProductQuery({"class":"com.helijia.item.api.service.ItemProductService$ItemProductQuery","artisanId":"11150a7f733942168960d85e80643c22","rows": 10000,"offset": 0,"isDel": 0})
....未经允许请勿转载:程序喵 » Dubbo telnet invoke 内部类找不到?盘它!
程序喵