[jcifs] Re: Write files to shared location
Michael B Allen
ioplex at gmail.com
Mon Dec 8 19:18:20 GMT 2008
On Mon, Dec 8, 2008 at 10:15 AM, Duseja, Sushil
<sushil.duseja at fiserv.com> wrote:
> Hello Mike,
> Thanks for the response.
> You are right; I am using multiple threads with one SmbFile instance but
> that is precisely my requirement. I need to use multiple threads for the
> processing (that includes creating files).
The SmbFile class is not thread-safe. Specifically you cannot create
one single instance of an SmbFile object and have multiple threads
operate on it simultaneously.
> Can you please suggest a workaround?
The solution is very simple - just create separate SmbFile objects as
necessary to perform the desired operation. Meaning, each thread must
have it's own SmbFile instance to work on. That is thread-safe.
However, obviously it is not ok to have more than one thread work on
the same exact *file*.
> Or else, can you please let me know
> if I can use java.io.File instance for my purpose (creating files at
> password protected network location)?
All of the above mentioned behavior is also true of java.io.File so
I'm not sure if using that would help you.
> -----Original Message-----
> From: Michael B Allen [mailto:ioplex at gmail.com]
> Sent: Monday, December 08, 2008 12:50 AM
> To: Duseja, Sushil
> Cc: jcifs at lists.samba.org
> Subject: Re: Write files to shared location
> On Sun, Dec 7, 2008 at 1:45 PM, Duseja, Sushil
> <sushil.duseja at fiserv.com> wrote:
>> I am required to write/save (large number of) files (approx. 10000) to
>> (secured) shared drive location (using jCIFS 1.3.1). If a file with
> the same
>> name already exists, a new file needs to be created with an index
>> than the previous one.
>> I am using the constuctor -
>> SmbFile("smb://domain;username:password@server/..../") or this purpose
> and I
>> can connect to the shared location successfully; however during the
>> of files, after generating few files, an Smbexception is thrown.
>> Here's the stacktrace:-
>> jcifs.smb.SmbException: The parameter is incorrect.
>> at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:542)
>> at jcifs.smb.SmbTransport.send(SmbTransport.java:644)
>> at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:356)
>> at jcifs.smb.SmbSession.send(SmbSession.java:234)
>> at jcifs.smb.SmbTree.treeConnect(SmbTree.java:161)
>> at jcifs.smb.SmbTree.send(SmbTree.java:66)
>> at jcifs.smb.SmbFile.send(SmbFile.java:729)
>> at jcifs.smb.SmbFile.queryPath(SmbFile.java:1308)
>> at jcifs.smb.SmbFile.exists(SmbFile.java:1362)
> Unless you're doing something bad like using multiple threads with the
> same SmbFile instance, the "parameter is incorrect" error should never
> occur and thus this would be a bug.
> The fastest way to find out what's going on is to get a packet
> capture. If you do get a packet capture of the error, make sure you
> send it to me directly. Do not post packet captures to public mailing
> PS: It's considered very bad form to use credentials in the URL. Use
> (and re-use) an NtlmPasswordAuthentication object.
> Michael B Allen
> PHP Active Directory SPNEGO SSO
Michael B Allen
PHP Active Directory SPNEGO SSO
More information about the jcifs