[jcifs] jcifs.smb.SmbException: The handle is invalid.

Michael B Allen ioplex at gmail.com
Mon Jan 6 00:08:06 MST 2014


On Thu, Nov 28, 2013 at 9:04 AM, btandel <bhargav.tandel at highq.com> 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/


More information about the jCIFS mailing list