SFTP Tutorial

Help
Shant007
2006-10-19
2013-02-24
  • Shant007

    Shant007 - 2006-10-19

    Hi,

    Following is my env.:
    App Server: JBoss
    Client: IE
    JDK: 142_10

    Trying to write a snippet in JSP to connect to SFTP server using JFTP. Can someone provide me some kind of tutorial to start with.

    Though I have tried the following code but it asks for allowing the host key:

    SshClient w_sshClient = new SshClient();
    w_sshClient.connect("myHost");

    On "Yes", it gets connected to the sftp server successfully.

    Kindly treat it urgent and important.

    Thanks in advance.
    -Shant

     
    • Shant007

      Shant007 - 2006-10-20

      Got the problem cracked...

      But now I have another issue. I am trying to delete a file from SFTP server. I already have the required permission.

      Following is the code snippet:

      sftpConn.removeFileOrDir(myfile);

      and following is the exception trace:
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  - java.lang.NullPointerException
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at com.sshtools.j2ssh.sftp.SftpFile.isDirectory(Unknown Source)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at com.sshtools.j2ssh.sftp.SftpFile.delete(Unknown Source)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at net.sf.jftp.net.SftpConnection.removeFileOrDir(SftpConnection.java:188)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jsp.testSFTP_jsp._jspService(testSFTP_jsp.java:102)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
      2006-10-20 09:43:38,890 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
      2006-10-20 09:43:39,000 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      2006-10-20 09:43:39,125 [http-0.0.0.0-8080-Processor25] INFO  -         at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
      2006-10-20 09:43:39,187 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      2006-10-20 09:43:39,203 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  -         at java.lang.Thread.run(Thread.java:534)
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  - Removal failed (java.lang.NullPointerException).
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  - > Removal failed (java.lang.NullPointerException).
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  - java.lang.NullPointerException
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  -         at com.sshtools.j2ssh.sftp.SftpFile.isDirectory(Unknown Source)
      2006-10-20 09:43:39,281 [http-0.0.0.0-8080-Processor25] INFO  -         at com.sshtools.j2ssh.sftp.SftpFile.delete(Unknown Source)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at net.sf.jftp.net.SftpConnection.removeFileOrDir(SftpConnection.java:188)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jsp.testSFTP_jsp._jspService(testSFTP_jsp.java:102)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      2006-10-20 09:43:39,375 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,468 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,578 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      2006-10-20 09:43:39,671 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      2006-10-20 09:43:39,765 [http-0.0.0.0-8080-Processor25] INFO  -         at java.lang.Thread.run(Thread.java:534)

      Kindly help me in getting this resolved.
      Thanks in advance.

       
    • Jake Kasprzak

      Jake Kasprzak - 2006-11-01

      Hello.

      Thank you for your interest in this software. If you would like some sort of tutorial on how to use the SFTP API, perhaps I could post more information on how that could be done. However, I do have a few questions for you.

      Has this happened with every file that you have tried to delete? Have you tried deleting both files and directories? And information on the server that you are connecting to could perhaps help.

      I personally have not seen this happen in the time that I have used the API, but I'll do what I can to help. Perhaps I could give more information on how this can be done, once I have the time.

      Thanks,

      J.K.

       
    • Cyberdemon

      Cyberdemon - 2007-03-15

      Hi, this was fixed recently by a contributed patch - please try 1.50-pre1 (webstart).

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks