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

jcifsatish javasatheesh at gmail.com
Tue Jun 9 15:40:03 GMT 2009


yes, it is a bug that I should close the outputstream when there is an
exception. I'll change it.
But the other place where I am trying to create new file, ideally it is
executing only once. If the execution is success, it is coming out from the
loop. The idea for looping is just to check once again if the file system is
down or some issues happened with file system in case of any reasons. So
basically if the file creation is successful, it will come out of that at
first attempt. 
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? 
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.. 
Can you suggest at which scenario ideally "The system cannot find the path
specified" error should come?

Thank you.


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.



More information about the jcifs mailing list