org.junit.ComparisonFailure: expected:<exitCode=[COMPLETED;exitDescription=]> but was:<exitCode=[FAILED;exitDescription=org.springframework.integration.MessageDeliveryException: Failed to transfer file [target/workingDir/Profils-example.zip] from local working directory to remote FTP directory.

Spring JIRA | Brice Dutheil | 4 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    There is an exception thrown by JSCH if the remote-directory starts with a slash "/". For example if the outbound adapter is configured in the following way, notice the "/target" {code:xml} <int-sftp:outbound-channel-adapter id="sftpOutboundAdapter" session-factory="sftpSessionFactory" channel="outputChannel" remote-directory="/target" remote-filename-generator="fileNameGenerator" remote-file-separator="/" auto-create-directory="true" /> {code} Then we'll have the following stacktrace: {code:java}org.junit.ComparisonFailure: <Click to see difference> org.junit.ComparisonFailure: expected:<exitCode=[COMPLETED;exitDescription=]> but was:<exitCode=[FAILED;exitDescription=org.springframework.integration.MessageDeliveryException: Failed to transfer file [target/workingDir/Profils-example.zip] from local working directory to remote FTP directory. at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:164) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) at com.myclient.batch.sftp.SftpTasklet.sendOverSftp(SftpTasklet.java:53) at com.myclient.batch.sftp.SftpTasklet.execute(SftpTasklet.java:41) at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195) at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:372) at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:121) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:293) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114) at org.springframework.batch.test.StepRunner.launchJob(StepRunner.java:169) at org.springframework.batch.test.StepRunner.launchStep(StepRunner.java:158) at org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:239) at org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:187) at com.myclient.batch.UploadCrmgpFilesIntegrationTest.should_upload_files_on_the_sftp_server(UploadCrmgpFilesIntegrationTest.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at com.myclient.core.test.rule.SftpRule$StartCloseSftpStatement.evaluate(SftpRule.java:71) at org.junit.rules.RunRules.evaluate(RunRules.java:18) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: org.springframework.core.NestedIOException: failed to create remote directory ''.; nested exception is 4: at org.springframework.integration.sftp.session.SftpSession.mkdir(SftpSession.java:177) at org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.mkdir(CachingSessionFactory.java:141) at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.makeDirectories(FileTransferringMessageHandler.java:291) at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.sendFileToRemoteDirectory(FileTransferringMessageHandler.java:234) at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:157) ... 61 more Caused by: 4: at com.jcraft.jsch.ChannelSftp.mkdir(ChannelSftp.java:1902) at org.springframework.integration.sftp.session.SftpSession.mkdir(SftpSession.java:174) ... 65 more Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:658) at com.jcraft.jsch.ChannelSftp.remoteAbsolutePath(ChannelSftp.java:2561) at com.jcraft.jsch.ChannelSftp.mkdir(ChannelSftp.java:1880) ... 66 more ]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at com.myclient.batch.UploadCrmgpFilesIntegrationTest.should_upload_files_on_the_sftp_server(UploadCrmgpFilesIntegrationTest.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at com.myclient.core.test.rule.SftpRule$StartCloseSftpStatement.evaluate(SftpRule.java:71) at org.junit.rules.RunRules.evaluate(RunRules.java:18) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) {code} I've tracked the "culprit" code to this method {{org.springframework.integration.file.remote.handler.FileTransferringMessageHandler#makeDirectories}}. For path "/target", the file will be appended with the separator "target/", that will processed then be processed, splitted in {{pathsToCreate}}, this list will contain two string {{""}} and {{"target"}}. While this could be an improvement in JSCH, I think Spring should handle this case, as the XSD documentation says it is possible to have directories starting with a slash "/". Plus the fix is fairly easy in removing empty string from the list.

    Spring JIRA | 4 years ago | Brice Dutheil
    org.junit.ComparisonFailure: expected:<exitCode=[COMPLETED;exitDescription=]> but was:<exitCode=[FAILED;exitDescription=org.springframework.integration.MessageDeliveryException: Failed to transfer file [target/workingDir/Profils-example.zip] from local working directory to remote FTP directory.
  2. 0

    There is an exception thrown by JSCH if the remote-directory starts with a slash "/". For example if the outbound adapter is configured in the following way, notice the "/target" {code:xml} <int-sftp:outbound-channel-adapter id="sftpOutboundAdapter" session-factory="sftpSessionFactory" channel="outputChannel" remote-directory="/target" remote-filename-generator="fileNameGenerator" remote-file-separator="/" auto-create-directory="true" /> {code} Then we'll have the following stacktrace: {code:java}org.junit.ComparisonFailure: <Click to see difference> org.junit.ComparisonFailure: expected:<exitCode=[COMPLETED;exitDescription=]> but was:<exitCode=[FAILED;exitDescription=org.springframework.integration.MessageDeliveryException: Failed to transfer file [target/workingDir/Profils-example.zip] from local working directory to remote FTP directory. at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:164) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) at com.myclient.batch.sftp.SftpTasklet.sendOverSftp(SftpTasklet.java:53) at com.myclient.batch.sftp.SftpTasklet.execute(SftpTasklet.java:41) at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195) at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:372) at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:121) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:293) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114) at org.springframework.batch.test.StepRunner.launchJob(StepRunner.java:169) at org.springframework.batch.test.StepRunner.launchStep(StepRunner.java:158) at org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:239) at org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:187) at com.myclient.batch.UploadCrmgpFilesIntegrationTest.should_upload_files_on_the_sftp_server(UploadCrmgpFilesIntegrationTest.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at com.myclient.core.test.rule.SftpRule$StartCloseSftpStatement.evaluate(SftpRule.java:71) at org.junit.rules.RunRules.evaluate(RunRules.java:18) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: org.springframework.core.NestedIOException: failed to create remote directory ''.; nested exception is 4: at org.springframework.integration.sftp.session.SftpSession.mkdir(SftpSession.java:177) at org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.mkdir(CachingSessionFactory.java:141) at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.makeDirectories(FileTransferringMessageHandler.java:291) at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.sendFileToRemoteDirectory(FileTransferringMessageHandler.java:234) at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:157) ... 61 more Caused by: 4: at com.jcraft.jsch.ChannelSftp.mkdir(ChannelSftp.java:1902) at org.springframework.integration.sftp.session.SftpSession.mkdir(SftpSession.java:174) ... 65 more Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:658) at com.jcraft.jsch.ChannelSftp.remoteAbsolutePath(ChannelSftp.java:2561) at com.jcraft.jsch.ChannelSftp.mkdir(ChannelSftp.java:1880) ... 66 more ]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at com.myclient.batch.UploadCrmgpFilesIntegrationTest.should_upload_files_on_the_sftp_server(UploadCrmgpFilesIntegrationTest.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at com.myclient.core.test.rule.SftpRule$StartCloseSftpStatement.evaluate(SftpRule.java:71) at org.junit.rules.RunRules.evaluate(RunRules.java:18) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) {code} I've tracked the "culprit" code to this method {{org.springframework.integration.file.remote.handler.FileTransferringMessageHandler#makeDirectories}}. For path "/target", the file will be appended with the separator "target/", that will processed then be processed, splitted in {{pathsToCreate}}, this list will contain two string {{""}} and {{"target"}}. While this could be an improvement in JSCH, I think Spring should handle this case, as the XSD documentation says it is possible to have directories starting with a slash "/". Plus the fix is fairly easy in removing empty string from the list.

    Spring JIRA | 4 years ago | Brice Dutheil
    org.junit.ComparisonFailure: expected:<exitCode=[COMPLETED;exitDescription=]> but was:<exitCode=[FAILED;exitDescription=org.springframework.integration.MessageDeliveryException: Failed to transfer file [target/workingDir/Profils-example.zip] from local working directory to remote FTP directory.

    Root Cause Analysis

    1. org.springframework.core.NestedIOException

      failed to create remote directory ''.; nested exception is 4:

      at org.springframework.integration.sftp.session.SftpSession.mkdir()
    2. org.springframework.integration
      FileTransferringMessageHandler.handleMessageInternal
      1. org.springframework.integration.sftp.session.SftpSession.mkdir(SftpSession.java:177)
      2. org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.mkdir(CachingSessionFactory.java:141)
      3. org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.makeDirectories(FileTransferringMessageHandler.java:291)
      4. org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.sendFileToRemoteDirectory(FileTransferringMessageHandler.java:234)
      5. org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:157)
      6. org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:164)
      6 frames
    3. Spring Integration Core
      AbstractMessageChannel.send
      1. org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
      2. org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
      3. org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
      4. org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
      5. org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
      5 frames
    4. com.myclient.batch
      SftpTasklet.execute
      1. com.myclient.batch.sftp.SftpTasklet.sendOverSftp(SftpTasklet.java:53)
      2. com.myclient.batch.sftp.SftpTasklet.execute(SftpTasklet.java:41)
      2 frames
    5. Spring Batch Core
      TaskletStep$ChunkTransactionCallback.doInTransaction
      1. org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386)
      1 frame
    6. Spring Tx
      TransactionTemplate.execute
      1. org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
      1 frame
    7. Spring Batch Core
      StepContextRepeatCallback.doInIteration
      1. org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
      2. org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
      2 frames
    8. Spring Batch Infrastructure
      RepeatTemplate.iterate
      1. org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
      2. org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
      3. org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
      3 frames
    9. Spring Batch Core
      SimpleJobLauncher$1.run
      1. org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250)
      2. org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)
      3. org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
      4. org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:372)
      5. org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:121)
      6. org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:293)
      7. org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
      7 frames
    10. Spring Core
      SyncTaskExecutor.execute
      1. org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
      1 frame
    11. Spring Batch Core
      SimpleJobLauncher.run
      1. org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
      1 frame
    12. org.springframework.batch
      JobLauncherTestUtils.launchStep
      1. org.springframework.batch.test.StepRunner.launchJob(StepRunner.java:169)
      2. org.springframework.batch.test.StepRunner.launchStep(StepRunner.java:158)
      3. org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:239)
      4. org.springframework.batch.test.JobLauncherTestUtils.launchStep(JobLauncherTestUtils.java:187)
      4 frames
    13. com.myclient.batch
      UploadCrmgpFilesIntegrationTest.should_upload_files_on_the_sftp_server
      1. com.myclient.batch.UploadCrmgpFilesIntegrationTest.should_upload_files_on_the_sftp_server(UploadCrmgpFilesIntegrationTest.java:48)
      1 frame
    14. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      3 frames
    15. JUnit
      InvokeMethod.evaluate
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      4 frames
    16. Spring TestContext
      RunAfterTestMethodCallbacks.evaluate
      1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      2 frames
    17. com.myclient.core
      SftpRule$StartCloseSftpStatement.evaluate
      1. com.myclient.core.test.rule.SftpRule$StartCloseSftpStatement.evaluate(SftpRule.java:71)
      1 frame
    18. JUnit
      RunRules.evaluate
      1. org.junit.rules.RunRules.evaluate(RunRules.java:18)
      1 frame
    19. Spring TestContext
      SpringJUnit4ClassRunner.runChild
      1. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      2. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      2 frames
    20. JUnit
      ParentRunner$2.evaluate
      1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      2. org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      3. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      4. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      5. org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      6. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      6 frames
    21. Spring TestContext
      RunAfterTestClassCallbacks.evaluate
      1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      2 frames
    22. JUnit
      ParentRunner.run
      1. org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      1 frame
    23. Spring TestContext
      SpringJUnit4ClassRunner.run
      1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      1 frame
    24. JUnit
      JUnitCore.run
      1. org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      1 frame
    25. IntelliJ junit4 module
      JUnit4IdeaTestRunner.startRunnerWithArgs
      1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
      1 frame
    26. IDEA
      JUnitStarter.main
      1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
      2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
      2 frames
    27. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      3 frames
    28. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      1 frame