Skip to content

Dubbo Telnet Unsupported command: ls #5690

@sunlongv587

Description

@sunlongv587
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.5
  • Operating System version: macOs Mojave 10.14.6
  • Java version: 1.8

Steps to reproduce this issue

  1. 正常启动项目后无法使用telnet的ls,cd,invoke等命令;
  2. 自己通过debug发现,在读取/META-INF/dubbo/internal/org.apache.dubbo.remoting.telnet.TelnetHandler这个配置文件的时候,在解析第6到14这几行的时候,出现了类加载失败的情况。
  3. 于是我便去源码中找了这几个类,发现它们的包结构和之前的版本2.7.4.1有所不同。
  4. 这几个类由org.apache.dubbo.rpc.protocol.dubbo.telnet包移动到了org.apache.dubbo.qos.legacy这个包下面。
  5. 我不知道我有没有找到根本原因,但这一定是其中之一,目前也有一个解决办法,并且我已经使用这个方法解决了这个问题。我把这些加载失败的Telnet类,放到了Telnet扩展中。

解决方案

把临时解决方案贴上来,希望能帮助遇到同样问题的小伙伴。
在项目resources目录中添加META-INF/dubbo/org.apache.dubbo.remoting.telnet.TelnetHandler文本文件,然后将加载失败的类包名修改后,配置到文件中。

文件内容如下:

ls=org.apache.dubbo.qos.legacy.ListTelnetHandler
ps=org.apache.dubbo.qos.legacy.PortTelnetHandler
cd=org.apache.dubbo.qos.legacy.ChangeTelnetHandler
pwd=org.apache.dubbo.qos.legacy.CurrentTelnetHandler
invoke=org.apache.dubbo.qos.legacy.InvokeTelnetHandler
trace=org.apache.dubbo.qos.legacy.TraceTelnetHandler
count=org.apache.dubbo.qos.legacy.CountTelnetHandler
select=org.apache.dubbo.qos.legacy.SelectTelnetHandler
shutdown=org.apache.dubbo.qos.legacy.ShutdownTelnetHandler
clear=org.apache.dubbo.remoting.telnet.support.command.ClearTelnetHandler
exit=org.apache.dubbo.remoting.telnet.support.command.ExitTelnetHandler
help=org.apache.dubbo.remoting.telnet.support.command.HelpTelnetHandler
status=org.apache.dubbo.remoting.telnet.support.command.StatusTelnetHandler
log=org.apache.dubbo.remoting.telnet.support.command.LogTelnetHandler

在项目中添加配置项:

dubbo.protocol.telnet=clear,exit,help,status,log,ls,ps,cd,pwd,invoke,trace,count,select,shutdown

使用方法在官方文档中有说明:扩展telnet
这个问题修改/META-INF/dubbo/internal/org.apache.dubbo.remoting.telnet.TelnetHandler的文件内容后就会解决,如有使用不当之处,还望开发者回复。

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

What do you expected from the above steps?

Actual Result

What actually happens?

If there is an exception, please attach the exception trace:

Unsupported command: ls

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugBugs to being fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions