Open icstreispe opened 2 years ago
Show, please, the whole stack trace for such an error.
The RemoteFileUtils.makeDirectories()
has a logic like this:
for (String pathToCreate : pathsToCreate) {
if (logger.isDebugEnabled()) {
logger.debug("Creating '" + pathToCreate + "'");
}
session.mkdir(pathToCreate);
}
So, if you add a DEBUG logging level for the org.springframework.integration.smb.session
category, you would see what is going to be created against remote session.
Tell us also, please, how it works if you don't have that /
in the end of your path.
full path from log: int2/PRJ/data/20220303/provider/IN/ int2/PRJ/data/ exists already 20220303/provider/IN/ - do not exist yet
1
jcifs.smb.SmbException: The network name cannot be found. at jcifs.smb.SmbTransportImpl.checkStatus2(SmbTransportImpl.java:1467) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTransportImpl.checkStatus(SmbTransportImpl.java:1578) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTransportImpl.sendrecv(SmbTransportImpl.java:1027) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTransportImpl.send(SmbTransportImpl.java:1549) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:409) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:347) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTreeImpl.treeConnect(SmbTreeImpl.java:611) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTreeConnection.connectTree(SmbTreeConnection.java:614) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTreeConnection.connectHost(SmbTreeConnection.java:568) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTreeConnection.connectHost(SmbTreeConnection.java:489) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTreeConnection.connect(SmbTreeConnection.java:465) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbTreeConnection.connectWrapException(SmbTreeConnection.java:426) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbFile.ensureTreeConnected(SmbFile.java:573) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbFile.exists(SmbFile.java:873) ~[jcifs-2.1.28.jar:na] at jcifs.smb.SmbFile.mkdirs(SmbFile.java:1702) ~[jcifs-2.1.28.jar:na] at org.springframework.integration.smb.session.SmbSession.mkdir(SmbSession.java:276) ~[spring-integration-smb-1.2.1.RELEASE.jar:na] at org.springframework.integration.file.remote.RemoteFileUtils.tryCreateRemoteDirectory(RemoteFileUtils.java:83) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileUtils.makeDirectories(RemoteFileUtils.java:73) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:561) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.doSend(RemoteFileTemplate.java:353) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.lambda$send$0(RemoteFileTemplate.java:314) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:452) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:314) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:302) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:294) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:207) ~[spring-integration-file-5.5.7.jar:5.5.7] at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:56) ~[spring-integration-core-5.5.7.jar:5.5.7] ....
2
22:20:54.086 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - New org.springframework.integration.smb.session.SmbSession created. 22:20:54.092 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/provider/IN/] for path [int2/PRJ/data/20220303/provider/IN/]. 22:20:54.120 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/provider/IN] for path [int2/PRJ/data/20220303/provider/IN]. 22:20:54.132 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/provider] for path [int2/PRJ/data/20220303/provider]. 22:20:54.142 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303] for path [int2/PRJ/data/20220303]. 22:20:54.152 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/] for path [int2/PRJ/data/]. 22:20:54.152 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/] for path [int2/PRJ/data]. 22:20:54.172 [http-nio-9990-exec-2] DEBUG o.s.i.s.s.SmbRemoteFileTemplate - Creating 'int2/PRJ/data/20220303' 22:20:54.182 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/] for path [int2/PRJ/data/20220303/]. 22:20:54.182 [http-nio-9990-exec-2] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/] for path [int2/PRJ/data/20220303].
... 4
22:51:15.756 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - New org.springframework.integration.smb.session.SmbSession created. 22:51:15.756 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/provider/IN/] for path [int2/PRJ/data/20220303/provider/IN/]. 22:51:15.839 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/provider/IN] for path [int2/PRJ/data/20220303/provider/IN]. 22:51:15.889 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303/provider] for path [int2/PRJ/data/20220303/provider]. 22:51:15.950 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data/20220303] for path [int2/PRJ/data/20220303]. 22:51:15.999 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/data] for path [int2/PRJ/data]. 22:51:16.009 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ] for path [int2/PRJ]. 22:51:16.059 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2] for path [int2]. 22:51:16.059 [http-nio-9990-exec-6] DEBUG o.s.i.s.s.SmbRemoteFileTemplate - Creating 'int2' 22:51:16.109 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/] for path [int2/]. 22:51:16.109 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/] for path [int2]. 22:51:16.219 [http-nio-9990-exec-6] INFO o.s.i.smb.session.SmbSession - Successfully created remote directory [int2] in share [smb://user:Password123%40@host:0/vfs_dev_00009]. 22:51:16.219 [http-nio-9990-exec-6] DEBUG o.s.i.s.s.SmbRemoteFileTemplate - Creating 'int2/PRJ' 22:51:16.229 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/] for path [int2/PRJ/]. 22:51:16.229 [http-nio-9990-exec-6] DEBUG o.s.i.smb.session.SmbSession - Created new jcifs.smb.SmbFile[smb://user:Password123%40@host:0/int2/PRJ/] for path [int2/PRJ]. 22:51:16.295 [http-nio-9990-exec-6] DEBUG o.s.web.servlet.DispatcherServlet - Failed to complete request: org.springframework.messaging.MessageDeliveryException:
This is the part of JCIFS where that exception is thrown:
default:
if ( log.isDebugEnabled() ) {
log.debug("Error code: 0x" + Hexdump.toHexString(resp.getErrorCode(), 8) + " for " + req.getClass().getSimpleName());
}
throw new SmbException(resp.getErrorCode(), null);
}
Doesn't looks like there is something we can do with this problem in this project. I suggest you to raise the concern with JCIFS community or your SMB vendor.
Perhaps you got some limits for your requests?..
seems that I found out the problem in the end:
smbRemoteFileTemplate should be initialized with a SmbSessionFactory
object whose value of its shareAndDir
property should contain an /
at the end
Hm.
We have a logic in there in the SmbConfig
like this:
if (!path.startsWith("/")) {
path = "/" + path;
}
According to your findings it looks like we also have to add /
into the end.
If that is what you are thinking, too, feel free to contribute the fix.
Thank you!
Hm. We have a logic in there in the
SmbConfig
like this:if (!path.startsWith("/")) { path = "/" + path; }
According to your findings it looks like we also have to add
/
into the end.If that is what you are thinking, too, feel free to contribute the fix.
Thank you!
Not sure if this is a good idea to always force a forward slash at the end... I'd like to understand all the use cases before we allow this in the code.
As stated this is mitigated anyways by the configuration setting in the SmbSessionFactory initialization.
Yes. We can live with that workaround and give it some flexibility when same configuration without "forward slash at the end" works in other environment.
I've created a class like this:
Then used it in a spring integration flow like this:
And when I run the flow everything is fine as long as at least the folders dir1, dir2, dir3 are already created, it managed to create dir4 if is not available. But if dir3 (or below, like dir1 or dir2) are not already created, the component fails with:
What can I do in order to make it create all the necessary folders, no matter how many?