Can you try calling payload.getContentMetadata().setContentLength(...)?
Also you might want to use a ByteSourcePayload instead, e.g.,

ByteSource byteSource = Files.asByteSource(
    new File("C:/Users/Udara/input.txt"));
Payload payload = new ByteSourcePayload(byteSource);
payload.getContentMetadata().setContentLength(byteSource.size())

This will allow the jclouds retry mechanism to work in the presence of
network failures.  InputStreamPayload are not retryable.

On Mon, Jun 16, 2014 at 09:22:15AM +0530, Nipun Udara wrote:
> Hi all
> 
> FileInputStream inputStream=new FileInputStream("C:/Users/Udara/input.txt");
>         try{
>           ssh.connect();
>           Payload payload=new InputStreamPayload(inputStream);
>           ssh.put("input.txt",payload);
>         }finally {
>             if (ssh!=null){
>                 ssh.disconnect();
>             }
>         }
> 
> when i use Jclouds sshClient put method above i got the following error,
> 
> [ERROR] <<
> (ec2-user:rsa[fingerprint(f7:fd:af:ae:25:0b:d3:99:2a:c2:ee:8c:83:be:92:0c),sha1(0f:4b:9e:f7:a7:f8:b1:4e:f4:7c:68:3b:2e:e2:e7:68:f3:25:8c:32)]@
> 54.85.181.97:22) error acquiring Put(path=[input.txt]) (not retryable): null
> java.lang.NullPointerException
> at
> org.jclouds.sshj.SshjSshClient$PutConnection$1.getLength(SshjSshClient.java:323)
> at
> net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.upload(SFTPFileTransfer.java:182)
>  at
> net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.access$100(SFTPFileTransfer.java:172)
> at net.schmizz.sshj.sftp.SFTPFileTransfer.upload(SFTPFileTransfer.java:70)
>  at net.schmizz.sshj.sftp.SFTPClient.put(SFTPClient.java:248)
> at
> org.jclouds.sshj.SshjSshClient$PutConnection.create(SshjSshClient.java:314)
>  at
> org.jclouds.sshj.SshjSshClient$PutConnection.create(SshjSshClient.java:290)
> at org.jclouds.sshj.SshjSshClient.acquire(SshjSshClient.java:196)
>  at org.jclouds.sshj.SshjSshClient.put(SshjSshClient.java:346)
> at org.apache.airavata.gfac.utils.JCloudsFileTransfer.uploadFileToEc2(JCl
> 
>  I can put strings or StringPayLoads but when i use InputStreamPayloads  i
> got this error. Any help regarding this
> 
> Regards
> Nipun Udara

-- 
Andrew Gaul
http://gaul.org/

Reply via email to