Re: jcifs.smb.SmbException: The handle is invalid.

Michael B Allen <[email protected]> Mon, 6 Jan 2014 02:08:06 -0500
Newsgroups gmane.network.samba.java
Message-ID <CAGMFw4gyXaso-xbRdT_gXB2Us6wFrtiSqBTgDE_K4s11hu9C4g@mail.gmail.com>
On Thu, Nov 28, 2013 at 9:04 AM, btandel <[email protected]> wrote:
> I am getting jcifs.smb.SmbException: The handle is invalid while copying
> a file. This error occurs in the middle of copying.
>
> SmbFileInputStream fin = null;
> SmbFile file = new SmbFile("path");
> fin = new SmbFileInputStream(file);
>
> FileOutputStream fos = null;
> File tmpFile = File.createTempFile("fileName", "docextention");
> try
> {
>         fos = new FileOutputStream(tmpFile);
>         byte[] b = new byte[1048576];
>         int count = 0;
>         while ((count = fin.read(b)) > 0)
>         {
>                 fos.write(b, 0, count);
>         }
>         // System.out.println("fos" + fos.toString());
> }
> catch (Exception e)
> {
>         logger.error(e.getMessage());
>         new ExceptionHandler().exceptionMail(e);
> }
>
> Error is generated from line : while ((count = fin.read(b)) > 0)
>
> jcifs.smb.SmbException: The handle is invalid.
> <br>    at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563)
> <br>    at jcifs.smb.SmbTransport.send(SmbTransport.java:663)
<snip>

Hi btandel,

The "handle is invalid" error is coming from the server. This is the
sort of error you might get if the file was deleted from the server
while you were in the middle of reading it.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/