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

jcifsatish javasatheesh at gmail.com
Fri Jun 26 11:48:39 GMT 2009


This issue was identified in the applications. It is due to multiple
instances running for the same application.
Thank you for all your support.

Michael B Allen wrote:
> 
> On Tue, Jun 9, 2009 at 11:40 AM, jcifsatish<javasatheesh at gmail.com> wrote:
>> I am getting issue here could be, due to multi threading, the folder/file
>> could have been already created due to other thread process. But I do not
>> understand the meaning of "The system cannot find the path specified"
>> error
>> message. Why is it showing this message in case of the file/folder has
>> been
>> already created?
> 
> The createNewFile method just does:
> 
>   close(open0(O_RDWR | O_CREAT | O_EXCL, 0, ATTR_NORMAL, 0), 0L);
> 
> so the O_CREAT | O_EXCL is sent to the server which is then
> responsible for *creat*ing the file *excl*usively for the caller and
> therefore multithreading should not be an issue.
> 
> That is unless your getSmbFile method is returning an instance that
> another thread may use. You cannot have multiple threads operating on
> the same SmbFile instance. I assume your getSmbFile method is
> ultimately calling "new SmbFile" with each call.
> 
>> I have seen your other posts for 'The system cannot find the path
>> specified'
>> errors. You have mentioned that it is due to IP address conventions and
>> it
>> has been resolved in new versions..
> 
> There are many conditions that can trigger the 'system cannot find the
> path specified' error. Previous posts about the error are almost
> certainly irrelevant.
> 
> Mike
> 
>> Michael B Allen wrote:
>>>
>>> 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/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/jcifs.smb.SmbException%3A-The-system-cannot-find-the-path-specified.-tp23943395p23945516.html
>> Sent from the Samba - jcifs mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Michael B Allen
> Java Active Directory Integration
> http://www.ioplex.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/jcifs.smb.SmbException%3A-The-system-cannot-find-the-path-specified.-tp23943395p24218872.html
Sent from the Samba - jcifs mailing list archive at Nabble.com.



More information about the jcifs mailing list