org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents.

Spring JIRA | Andy Flury | 4 years ago
  1. 0

    I'm trying to use the mail-attachments sample with the following imap-idle-channel-adapter: <int-mail:imap-idle-channel-adapter id="customAdapter" store-uri="imaps://user:pw@imap.gmail.com:993/inbox" channel="inboundChannel" auto-startup="true" should-delete-messages="false" should-mark-messages-as-read="false" java-mail-properties="javaMailProperties"/> But I always receive the following error: Exception in thread "pool-1-thread-1" org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents. at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:73) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137) 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 org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128) at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288) at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149) at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:92) at org.springframework.integration.mail.ImapIdleChannelAdapter.access$2200(ImapIdleChannelAdapter.java:56) at org.springframework.integration.mail.ImapIdleChannelAdapter$1.run(ImapIdleChannelAdapter.java:224) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents. at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:76) at org.springframework.integration.transformer.AbstractMessageProcessingTransformer.transform(AbstractMessageProcessingTransformer.java:56) at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67) ... 17 more Caused by: java.lang.IllegalStateException: Error while retrieving the email contents. at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:195) at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:251) at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMessage(EmailParserUtils.java:99) at org.springframework.integration.samples.mailattachments.support.EmailTransformer.transformit(EmailTransformer.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57) at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102) at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126) at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:227) at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:127) at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73) ... 19 more Caused by: javax.mail.FolderClosedException at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:639) at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:189) ... 35 more If I set a breakpoint in EmailParserUtils on line 189 and wait a few seconds after an email arrives, everything works fine!

    Spring JIRA | 4 years ago | Andy Flury
    org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents.
  2. 0

    I'm trying to use the mail-attachments sample with the following imap-idle-channel-adapter: <int-mail:imap-idle-channel-adapter id="customAdapter" store-uri="imaps://user:pw@imap.gmail.com:993/inbox" channel="inboundChannel" auto-startup="true" should-delete-messages="false" should-mark-messages-as-read="false" java-mail-properties="javaMailProperties"/> But I always receive the following error: Exception in thread "pool-1-thread-1" org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents. at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:73) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137) 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 org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128) at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288) at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149) at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:92) at org.springframework.integration.mail.ImapIdleChannelAdapter.access$2200(ImapIdleChannelAdapter.java:56) at org.springframework.integration.mail.ImapIdleChannelAdapter$1.run(ImapIdleChannelAdapter.java:224) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents. at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:76) at org.springframework.integration.transformer.AbstractMessageProcessingTransformer.transform(AbstractMessageProcessingTransformer.java:56) at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67) ... 17 more Caused by: java.lang.IllegalStateException: Error while retrieving the email contents. at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:195) at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:251) at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMessage(EmailParserUtils.java:99) at org.springframework.integration.samples.mailattachments.support.EmailTransformer.transformit(EmailTransformer.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57) at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102) at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126) at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:227) at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:127) at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73) ... 19 more Caused by: javax.mail.FolderClosedException at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:639) at org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:189) ... 35 more If I set a breakpoint in EmailParserUtils on line 189 and wait a few seconds after an email arrives, everything works fine!

    Spring JIRA | 4 years ago | Andy Flury
    org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: java.lang.IllegalStateException: Error while retrieving the email contents.
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    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. javax.mail.FolderClosedException

      No message provided

      at javax.mail.internet.MimeBodyPart.getContent()
    2. JavaMail API
      MimeBodyPart.getContent
      1. javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:639)
      1 frame
    3. org.springframework.integration
      EmailTransformer.transformit
      1. org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:189)
      2. org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMultipart(EmailParserUtils.java:251)
      3. org.springframework.integration.samples.mailattachments.support.EmailParserUtils.handleMessage(EmailParserUtils.java:99)
      4. org.springframework.integration.samples.mailattachments.support.EmailTransformer.transformit(EmailTransformer.java:41)
      4 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. Spring Expression Language (SpEL)
      SpelExpression.getValue
      1. org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
      2. org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84)
      3. org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
      4. org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
      5. org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
      5 frames
    6. Spring Integration Core
      MessageProducerSupport.sendMessage
      1. org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
      2. org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:227)
      3. org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:127)
      4. org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)
      5. org.springframework.integration.transformer.AbstractMessageProcessingTransformer.transform(AbstractMessageProcessingTransformer.java:56)
      6. org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67)
      7. org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134)
      8. org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
      9. org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137)
      10. org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
      11. org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
      12. org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
      13. org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
      14. org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
      15. org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
      16. org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
      17. org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
      18. org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:92)
      18 frames
    7. org.springframework.integration
      ImapIdleChannelAdapter$1.run
      1. org.springframework.integration.mail.ImapIdleChannelAdapter.access$2200(ImapIdleChannelAdapter.java:56)
      2. org.springframework.integration.mail.ImapIdleChannelAdapter$1.run(ImapIdleChannelAdapter.java:224)
      2 frames
    8. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      3. java.lang.Thread.run(Thread.java:662)
      3 frames