[英]Unknown Source Exception when using addProtocolCommandListener with library org.apache.commons.net.telnet.TelnetClient
I'm using the following library... 我正在使用以下库...
org.apache.commons.net.telnet.TelnetClient;
I have this piece of code which I am using to connect to a server. 我有这段代码用于连接服务器。
import org.apache.commons.net.*;
import org.apache.commons.net.ProtocolCommandListener
import org.apache.commons.net.ftp.FTPSClient
import org.apache.commons.net.telnet.TelnetClient;
String server = "some server";
String result = '';
//Create the telnet client and connect on port 43
TelnetClient telnetClient = new TelnetClient();
telnetClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
telnetClient.connect(server, 43);
When i get to the line with.... 当我排队时...
telnetClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
I get the following exception.... 我得到以下异常。
Caught: java.lang.NullPointerException Disconnected from the target VM, address: '127.0.0.1:3140', transport: 'socket' java.lang.NullPointerException at org.apache.commons.net.SocketClient.addProtocolCommandListener(SocketClient.java:772) at org.apache.commons.net.SocketClient$addProtocolCommandListener.call(Unknown Source) 捕获:java.lang.NullPointerException与目标VM断开连接,地址:'127.0.0.1:3140',传输:'socket'java.lang.NullPointerException,位于org.apache.commons.net.SocketClient.addProtocolCommandListener(SocketClient.java: 772)在org.apache.commons.net.SocketClient $ addProtocolCommandListener.call(未知来源)
Anybody know why I might be getting this exception? 有人知道为什么我可能会收到此异常吗? If I remove the line I don't so the exception is this line.
如果我删除该行,则不会,因此例外是此行。 And if i use the FTPS client i do not have this problem with SFTP from the same library!
如果我使用FTPS客户端,那么同一个库中的SFTP不会出现此问题!
Hi, thanks for responding, here is a simple example of some supported clients in the library, i'm guessing maybe that whois and ftp client do not support the listner !? 嗨,感谢您的答复,这是库中一些受支持的客户端的简单示例,我猜测也许whois和ftp客户端不支持列表器!
import org.apache.commons.net.*;
import org.apache.commons.net.ProtocolCommandListener;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.telnet.TelnetClient;
import org.apache.commons.net.whois.WhoisClient;
import java.io.PrintWriter;
public class WhoisExample
{
public static void main(String args[])
{
try {
WhoisClient whoisClient = new WhoisClient();
whoisClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
}
catch(Exception e) {
System.out.println("whois client exception" + e);
}
try {
TelnetClient telnetClient = new TelnetClient();
telnetClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
}
catch(Exception e) {
System.out.println("telnet client exception" + e);
}
try {
FTPClient ftpClient = new FTPClient();
ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
System.out.println("no ftp client exception here !");
}
catch(Exception e)
{
System.out.println("ftp client exception" + e);
}
}
}
I logged a bug with Apache commons net and it has been resolved as not a problem. 我使用Apache Commons Net记录了一个错误,该错误已解决为问题。
Basically .....'Some clients don't currently support the ProtocolCommand Listener.' 基本上……..“某些客户端当前不支持ProtocolCommand侦听器。”
You can find out more from the following link.... 您可以从以下链接中找到更多信息。
https://issues.apache.org/jira/browse/NET-608 https://issues.apache.org/jira/browse/NET-608
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.