[jcifs] jcifs.smb.SmbException: The system cannot find the path specified.

Michael B Allen ioplex at gmail.com
Tue Jun 9 14:43:19 GMT 2009


On Tue, Jun 9, 2009 at 9:56 AM, jcifsatish<javasatheesh at gmail.com> wrote:
>
> Hi, I am getting below error while creating file. My method is executing in
> multi thread model. Please suggest what could be the issue:
>
> Method calling in multi threaded environment:
> public void createFileWithContent(String fileStr, byte[] content, String
> serverLocation, int hashCode) {
>        SmbFile file = getSmbFile(fileStr, serverLocation);
>        if ( isFileExists(fileStr, serverLocation) )
>            throw new CCServiceException(ErrorCodes.DUPLICATE_FILE);
>
>        SmbFileOutputStream out = null;
>        for ( int count = 0; count < CCConstants.CONNECTION_COUNT; count++ )
> {
>            try {
>                file.createNewFile();

I don't know what the problem is but I don't think you can call
createNewFile in a loop like this. Or maybe you can but at least it
probably won't do anything after the first call. SmbFile objects are
partially immutable. You cannot call mkdir on the same instance twice,
if you set an attribute in one instance it will not be reflected in
the other and so on. So either move that createNewFile outside of the
loop do "new SmbFile" and and then createNewFile with each iteration.

>                out = new SmbFileOutputStream(file, false);

I'm not sure you can create multiple SmbFileOutputStream objects from
the same SmbFile instance because it will cause writes to use the same
file descriptor on the server but each SmbFileOutputStream has it's
own offset so each write will overwrite the last. I doubt that is what
you intended. Again, this is similar to the previous comment. Create a
separate SmbFile object for each SmbFileOutputStream instance.

Mike

>                if ( content != null ) {
>                    out.write(content);
>                }
>                break;
>            } catch ( IOException ioe ) {
>                logger.warn("Failed to write to the file: " + fileStr + "
> for " + (count + 1) + " times.");
>                ;
>                if ( count + 1 == CCConstants.CONNECTION_COUNT ) {
>                    logger.error("Error occurred while tring to write to the
> file: " + fileStr, ioe);
>                    throw new
> CCServiceException(ErrorCodes.CANNOT_CREATE_FILE);
>                }
>            } finally {
>                if ( out != null ) {
>                    try {
>
>                        out.close();
>                    } catch ( IOException e ) {
>                        logger.warn(e.getMessage());
>                    }
>                }
>            }
>        }
>    }
>
> File Path:
> ---------
> context path is :
> smb://MYUSER;mypwd:mydomain@v0-231.netapp-b2.shhq.bbc.com/ccss4
> full path is :
> smb://MYUSER;mypwd:mydomain@v0-231.netapp-b2.shhq.bbc.com/ccss4/PROD01/BC/WKFL/ER/TEMP/20090604/140826/1244124506462.cdf.1.tmp
>
> Error Message:
> -------------
> 2009-06-04 09:08:26 [ERROR]
> (com.bbc.app.onb.ac.common.util.SMBUtil.java:527) - Error occurred while
> tring to write to the file:
> PROD01/UP/WKFL/ER/TEMP/20090604/140826/1244124506462.cdf.1.tmp
> jcifs.smb.SmbException: The system cannot find the path specified.
>        at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:514)
>        at jcifs.smb.SmbTransport.send(SmbTransport.java:614)
>        at jcifs.smb.SmbSession.send(SmbSession.java:239)
>        at jcifs.smb.SmbTree.send(SmbTree.java:109)
>        at jcifs.smb.SmbFile.send(SmbFile.java:695)
>        at jcifs.smb.SmbFile.open0(SmbFile.java:887)
>        at jcifs.smb.SmbFile.createNewFile(SmbFile.java:2522)
>        at
> com.bbc.app.onb.ac.common.util.SMBUtil.createFileWithContent(SMBUtil.java:517)
>
> I would appreciate greatly if you could provide me your advice at the
> earliest.
>
> Thank You
> --
> View this message in context: http://www.nabble.com/jcifs.smb.SmbException%3A-The-system-cannot-find-the-path-specified.-tp23943395p23943395.html
> Sent from the Samba - jcifs mailing list archive at Nabble.com.
>
>



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


More information about the jcifs mailing list