[jcifs] Error writing to a share folder
Jose Luis Martinez Avial
jlmartinez at pb-santander.com
Fri Sep 13 17:00:28 MDT 2013
Hello,
I'm having some issues writing to a share folder in a Windows server (I don't know the specific windows version).I basically create a SmbFile, and then a SmbFileOutputStream with that file, and start writing on that stream in blocks of 100k:
private void writeFIS2server(InputStream fis, String path, String fileName) throws Exception {
log.debug("writeFIS2server start");
System.setProperty("jcifs.util.loglevel", "3");
OutputStream os = openTargetStream(smbDomain, smbUser, smbPassword, path + "/" + fileName);
copy(fis, os);
log.debug("writeFIS2server end");
}
private OutputStream openTargetStream(String domain, String user, String password, String unc) throws Exception {
return openTargetStream(new NtlmPasswordAuthentication(domain, user, password), unc);
}
private OutputStream openTargetStream(NtlmPasswordAuthentication auth, String unc) throws Exception {
SmbFile sFile = new SmbFile(unc, auth);
sFile.createNewFile();
return new SmbFileOutputStream(sFile);
}
private void copy(InputStream in, OutputStream out) throws IOException {
System.out.println("copy start");
// Transfer bytes from in to out
int bufferSize = 1024*100;
byte[] buf = new byte[bufferSize];
int len;
int counter = 1;
while ((len = in.read(buf)) > 0) {
System.out.println("Copying block "+counter+" with "+len+" bytes");
out.write(buf, 0, len);
out.flush();
counter++;
}
in.close();
out.close();
System.out.println("copy end");
}
}
The issue is that for each out.write, I see a bunch of logs:
jcifs.smb.SmbException: The system cannot find the file specified.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563)
at jcifs.smb.SmbTransport.send(SmbTransport.java:640)
at jcifs.smb.SmbSession.send(SmbSession.java:238)
at jcifs.smb.SmbTree.send(SmbTree.java:119)
[...]
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
doConnect: 0.0.0.0<00>/xxx.xxx.xxx.xxx
open0: \yyyyyy\DT1317500232.pdf
jcifs.smb.SmbException: The system cannot find the file specified.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563)
The file is copied correctly, but the error messages are bothering me. I'm using jcifs 1.3.17, with the default configuration, and I'm using the IP address of the server, not the server name. What could be the problem. I took a tcpdump while copying the files, so I can provide it if needed.
Thank you all
JL
-------------------------------
José Luis Martínez-Avial
Web Applications Global Head
Information Technology
Santander Private Banking
1401 Brickell Avenue, Suite 1500, Miami FL 33131
Phone: 305.539.2417
Internet communications are not secure and therefore Banco
Santander International does not accept legal responsibility for
the contents of this message. Any views or opinions presented
are solely those of the author and do not necessarily represent
those of Banco Santander International unless otherwise
specifically stated.
Las comunicaciones vía Internet no son seguras y, por lo tanto,
Banco Santander International no asume responsabilidad legal
ni de ningún otro tipo por el contenido de este mensaje.
Cualquier opinión transmitida pertenece únicamente al autor y
no necesariamente representa la opinión de Banco Santander
International, a no ser que esté expresamente detallado.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20130913/4ab2a02d/attachment-0001.html>
More information about the jCIFS
mailing list