org.springframework.messaging.MessageHandlingException: failed to write Message payload to file; nested exception is java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory)

Spring JIRA | Gunnar Hillert | 2 years ago
  1. 0

    This is either a feature/improvement *OR* a bug-report. This depends on which route we want to go. I have been working on the *spring-integration-zip* extension. When unzipping files, I may end up with files in sub-directories. A subsequent splitter, will generate individual messages for each file entry. Payloads may be of type *byte[]* and using a *file-outbound-channel-adapter*, it would be nice to recreate the nested file+directory structure. While you can use the *directory-expression*, it would have been nice, for simplicity reasons, to specify the directory as part of *FileHeaders.FILENAME*. E.g.: ...setHeader(FileHeaders.FILENAME, "dir/test2") However, this leads to a cryptic error message: {code} Exception in thread "main" org.springframework.messaging.MessageHandlingException: failed to write Message payload to file; nested exception is java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory) at org.springframework.integration.file.FileWritingMessageHandler.handleRequestMessage(FileWritingMessageHandler.java:309) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:277) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:239) at com.hillert.filetest.Main.main(Main.java:54) Caused by: java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:213) at org.springframework.integration.file.FileWritingMessageHandler.handleByteArrayMessage(FileWritingMessageHandler.java:379) at org.springframework.integration.file.FileWritingMessageHandler.handleRequestMessage(FileWritingMessageHandler.java:296) ... 9 more {code} A quick sample project is at: https://github.com/ghillert/si-file-test This raises ultimately the question: 1) Should FileHeaders.FILENAME be "directory-aware"? (only relative to base-output-directory) 2) Should we add something like FileHeaders.DIRECTORY? 3) State that we only support *directory-expression*? Even, if 3) is all we support. We should improve the error message, as it is cryptic. When using FileHeaders.FILENAME we should validate the value and ensure it does not contain path information. This may also somewhat relate to an old open Jira: INT-832 The official behavior should also be documented in the reference guide.

    Spring JIRA | 2 years ago | Gunnar Hillert
    org.springframework.messaging.MessageHandlingException: failed to write Message payload to file; nested exception is java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory)
  2. 0

    This is either a feature/improvement *OR* a bug-report. This depends on which route we want to go. I have been working on the *spring-integration-zip* extension. When unzipping files, I may end up with files in sub-directories. A subsequent splitter, will generate individual messages for each file entry. Payloads may be of type *byte[]* and using a *file-outbound-channel-adapter*, it would be nice to recreate the nested file+directory structure. While you can use the *directory-expression*, it would have been nice, for simplicity reasons, to specify the directory as part of *FileHeaders.FILENAME*. E.g.: ...setHeader(FileHeaders.FILENAME, "dir/test2") However, this leads to a cryptic error message: {code} Exception in thread "main" org.springframework.messaging.MessageHandlingException: failed to write Message payload to file; nested exception is java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory) at org.springframework.integration.file.FileWritingMessageHandler.handleRequestMessage(FileWritingMessageHandler.java:309) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:277) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:239) at com.hillert.filetest.Main.main(Main.java:54) Caused by: java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:213) at org.springframework.integration.file.FileWritingMessageHandler.handleByteArrayMessage(FileWritingMessageHandler.java:379) at org.springframework.integration.file.FileWritingMessageHandler.handleRequestMessage(FileWritingMessageHandler.java:296) ... 9 more {code} A quick sample project is at: https://github.com/ghillert/si-file-test This raises ultimately the question: 1) Should FileHeaders.FILENAME be "directory-aware"? (only relative to base-output-directory) 2) Should we add something like FileHeaders.DIRECTORY? 3) State that we only support *directory-expression*? Even, if 3) is all we support. We should improve the error message, as it is cryptic. When using FileHeaders.FILENAME we should validate the value and ensure it does not contain path information. This may also somewhat relate to an old open Jira: INT-832 The official behavior should also be documented in the reference guide.

    Spring JIRA | 2 years ago | Gunnar Hillert
    org.springframework.messaging.MessageHandlingException: failed to write Message payload to file; nested exception is java.io.FileNotFoundException: target/output/dir/test2.writing (No such file or directory)
  3. 0

    GitHub comment 1942#255760993

    GitHub | 2 months ago | Panciz
    org.springframework.messaging.MessageHandlingException: failed to write Message payload to file; nested exception is java.io.FileNotFoundException: C:\SIRIO-SA\RecipeTo\localhost_access_log.2016-09-19.txt.writing (Accesso negato)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    can't run an indexing service on wikipedia examples

    Google Groups | 2 years ago | Chung Chen
    java.io.FileNotFoundException: *log/index_wikipedia_2014-12-23T01:20:12.402Z.log (No such file or directory)*
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.io.FileNotFoundException

    target/output/dir/test2.writing (No such file or directory)

    at java.io.FileOutputStream.open()
  2. Java RT
    FileOutputStream.<init>
    1. java.io.FileOutputStream.open(Native Method)
    2. java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    2 frames
  3. org.springframework.integration
    FileWritingMessageHandler.handleRequestMessage
    1. org.springframework.integration.file.FileWritingMessageHandler.handleByteArrayMessage(FileWritingMessageHandler.java:379)
    2. org.springframework.integration.file.FileWritingMessageHandler.handleRequestMessage(FileWritingMessageHandler.java:296)
    2 frames
  4. Spring Integration Core
    AbstractMessageChannel.send
    1. org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
    2. org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    3. org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
    4. org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
    5. org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
    6. org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
    7. org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:277)
    8. org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:239)
    8 frames
  5. com.hillert.filetest
    Main.main
    1. com.hillert.filetest.Main.main(Main.java:54)
    1 frame