I'm trying to upload a file to a sftp server from an Android App using JSCH v. 0.1.55. However, I get an exception during the connection.
com.jcraft.jsch.JSchException: java.lang.InstantiationException: java.lang.Class<com.jcraft.jsch.UserAuthNone> has no zero argument constructor
at com.jcraft.jsch.Session.connect(Session.java:393)
at com.jcraft.jsch.Session.connect(Session.java:183)
Caused by: java.lang.InstantiationException: java.lang.Class<com.jcraft.jsch.UserAuthNone> has no zero argument constructor
at java.lang.Class.newInstance(Native Method)
at com.jcraft.jsch.Session.connect(Session.java:390)
This error seems to happen when the password is not set, but I checked with the debugger and all info are correct. Also, I can conect using FileZilla. Here is the code. The error is when executing session.connect();
Session session = null;
Channel channel = null;
try {
JSch jsch = new JSch();
session = jsch.getSession(user, host, port);
session.setPassword(password);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
config.put("PreferredAuthentications", "password");
session.setConfig(config);
session.connect();
// Code uploading the file
} catch (Exception ex) {
ex.printStackTrace();
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744658595a4586322.html
评论列表(0条)