Re: [JSch-users] Exceptions in ls, get or rm commands
Status: Alpha
Brought to you by:
ymnk
From: Ying L. <y0...@ho...> - 2006-07-15 03:37:08
|
Hi, Thanks all for your valuable advise~ I shall try them out on Mon & notify you the results then....... In the meantime, may I know if there's any API for the jsch library?? Thank you! Best regards, Ying >From: "Ying Lung" <y0...@ho...> >To: jsc...@li... >Subject: [JSch-users] Exceptions in ls, get or rm commands >Date: Fri, 14 Jul 2006 18:29:10 +0800 > >I don't understand why, but I keep getting SftpException or even >OutOfMemoryError when calling the ls, get or rm methods from >com.jcraft.jsch.ChannelSftp or connecting sftp channel ... The exceptions >are thrown in different points at different times (plus 1% chance of >finishing successfully)!! > >I would be really appreciate if someone could help~ Many thanks! > >----------- > >Here is a sample code of my program:- > > Session session = null; > ChannelSftp c = null; > > try { > System.out.println("initialize..."); > JSch jsch=new JSch(); > > System.out.println("get session..."); > String user = "ftpuser"; > String host = "127.0.0.1"; > session=jsch.getSession(user, host, 22); > > > System.out.println("connecting session..."); > String pwd = "password"; > MyUserInfo myUserInfo =new MyUserInfo(pwd); > session.setUserInfo(myUserInfo); > session.connect(); > > System.out.println("opening channel..."); > Channel channel=session.openChannel("sftp"); > System.out.println("connecting channel..."); > channel.connect(); > c=(ChannelSftp)channel; > > System.out.println("ls..."); > Vector files = c.ls("."); > for (int i = 0; i < files.size(); ++i) { > System.out.println("entry: "+files.elementAt(i)); > } > System.out.println("finished!"); > } catch (JSchException e) { > System.err.println("JSchException?!!"); > System.err.println(e.getMessage()); > e.printStackTrace(); > } catch (SftpException e) { > System.err.println("SftpException?!!"); > System.err.println(e.getMessage()); > e.printStackTrace(); > } catch (OutOfMemoryError e) { > System.err.println("OutOfMemory?!!"); > System.err.println(e.getMessage()); > e.printStackTrace(); > } finally { > if (session != null) > session.disconnect(); > if (c != null) > c.quit(); > } > > >----------------------------------------------------------------- > >And 5 of the possible outputs are as follows:- > >initialize... >get session... >connecting session... >opening channel... >connecting channel... >ls... >OutOfMemory?!! >Java heap space >java.lang.OutOfMemoryError: Java heap space > >initialize... >get session... >connecting session... >opening channel... >connecting channel... >SftpException?!! >null >4: > at com.jcraft.jsch.ChannelSftp.ls(Unknown Source) > at es.bkp.MySFTP.main(MySFTP.java:73) > >initialize... >get session... >connecting session... >opening channel... >connecting channel... >ls... >entry: drwxrwxrwx 1 0 0 0 Jul 14 7:49 ./ >entry: drwxrwxrwx 1 0 0 0 Jul 11 1:43 ../ >entry: dr-xr-xr-x 1 0 0 0 Jul 11 1:43 Application >Data/ >entry: drwxrwxrwx 1 0 0 0 Jul 14 7:49 Desktop/ >entry: dr-xr-xr-x 1 0 0 0 Jul 11 1:43 Favorites/ >entry: drwxrwxrwx 1 0 0 0 Feb 7 16:39 Local >Settings/ >entry: dr-xr-xr-x 1 0 0 0 Jul 11 1:43 My Documents/ >entry: drwxrwxrwx 1 0 0 0 Feb 7 16:39 NetHood/ >entry: -rw-rw-rw- 1 0 0 524288 Jul 12 11:44 NTUSER.DAT >entry: -rw-rw-rw- 1 0 0 1024 Jul 12 11:44 >NTUSER.DAT.LOG >entry: drwxrwxrwx 1 0 0 0 Feb 7 16:39 PrintHood/ >entry: dr-xr-xr-x 1 0 0 0 Jul 11 7:25 Recent/ >entry: dr-xr-xr-x 1 0 0 0 Jul 11 1:43 SendTo/ >entry: dr-xr-xr-x 1 0 0 0 Feb 7 16:39 Start Menu/ >entry: drwxrwxrwx 1 0 0 0 Feb 7 16:39 Templates/ >finished! > >initialize... >get session... >connecting session... >opening channel... >connecting channel... >OutOfMemory?!! >Java heap space >java.lang.OutOfMemoryError: Java heap space > >initialize... >get session... >connecting session... >opening channel... >connecting channel... >ls... >SftpException?!! >null >4: > at com.jcraft.jsch.ChannelSftp._sendCLOSE(Unknown Source) > at com.jcraft.jsch.ChannelSftp.ls(Unknown Source) > at es.bkp.MySFTP.main(MySFTP.java:72) > >_________________________________________________________________ >Learn English via Shopping Game, FREE! >http://www.linguaphonenet.com/BannerTrack.asp?EMSCode=MSN06-03ETFJ-0211E > > > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job >easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >JSch-users mailing list >JSc...@li... >https://lists.sourceforge.net/lists/listinfo/jsch-users _________________________________________________________________ Learn English via Shopping Game, FREE! http://www.linguaphonenet.com/BannerTrack.asp?EMSCode=MSN06-03ETFJ-0211E |