Hi Claus,

thanks for your prompt reply. We are currently running on Camel 2.17.4. 
Updating to a newer version is currently no solution. Also from my current 
understanding, this error is caused due to NIL-response from the mailserver, 
which might also happen in newer version, right?

In the logs I found the following (see attached trace):
A17 FETCH 165 (BODY.PEEK[1.1])
* 165 FETCH (BODY[1.1] NIL)

Regarding the proposal to just return an empty string: We faced this problem 
with another mail where (I think) the content was actually not empty (SMIME 
mail). So returning an empty string would be wrong. Unfortunately I'm not able 
to reproduce the problem and validate this statement.

A possible workaround that I found is to copy the whole Message via 
CopyConstructor of MimeMessage, as suggested here:
https://javaee.github.io/javamail/FAQ.html#imapserverbug

A possible fix for this problem could be done in the MailConsumer: 
- if a mail fails due to no-content exception, the above fix could be applied 
and the mail could be retried

What do you think?

Best regards,
Manuel Shenavai

-----Original Message-----
From: Claus Ibsen <claus.ib...@gmail.com> 
Sent: Donnerstag, 21. März 2019 08:05
To: users@camel.apache.org
Subject: Re: IMAP: No content

Hi

What version of Camel are you using?

And we could likely consider adding a check for this kind of exception
with "No content" error message as in the stacktraces and regard the
message as empty. Mind that the message is in english so we can only
check for that and not for other languages.

Also have you tried upgrading Camel and/or javax mail? It may work
better on newer versions.

On Wed, Mar 20, 2019 at 4:56 PM Shenavai, Manuel
<manuel.shena...@sap.com> wrote:
>
> Hi camel users,
>
>
>
> we are using the camel mail component to fetch mails from a mailserver. For 
> some mails the polling fails due to a IOException (see below).
>
>
>
> I attached the mail that causes the problem to this mail (slightly changed). 
> The mail has an empty body, so one could argue the exception is correct. But 
> for other mails with empty body there is no exception thrown.
>
>
>
> I found this post which seems to be the same problem, but without a solution:
>
> http://camel.465427.n5.nabble.com/IMAP-No-content-td5725535.html
>
>
>
> Anyone else came across this problem?
>
>
>
> Thanks in advance
>
> Best regards,
>
> Manuel
>
>
>
>
>
> Caused by: java.io.IOException: No content
>
>                 at 
> javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:115)
>
>                 at 
> com.sun.mail.handlers.text_plain.getContent(text_plain.java:80)
>
>                 at 
> javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:795)
>
>                 at 
> javax.activation.DataHandler.getContent(DataHandler.java:542)
>
>                 at 
> javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:657)
>
>                 at 
> org.apache.camel.component.mail.MailBinding.extractHeadersFromMail(MailBinding.java:614)
>
>                 at 
> com.sap.esb.camel.mail.endpoint.configurator.mail.binding.CustomMailBinding.extractHeadersFromMail(CustomMailBinding.java:24)
>
>                 at 
> com.sap.esb.camel.security.cms.smime.SMimeMailBinding.extractHeadersFromMail(SMimeMailBinding.java:292)
>
>                 at 
> com.sap.esb.camel.mail.endpoint.configurator.mail.impl.trace.TraceMailBindingWithDelegation.extractHeadersFromMail(TraceMailBindingWithDelegation.java:42)
>
>                 at 
> org.apache.camel.component.mail.MailMessage.populateInitialHeaders(MailMessage.java:116)
>
>                 ... 27 common frames omitted
>
> Caused by: javax.mail.MessagingException: No content
>
>                 at 
> com.sun.mail.imap.IMAPBodyPart.getContentStream(IMAPBodyPart.java:206)
>
>                 at 
> javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:99)
>
>                 ... 36 common frames omitted
>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
A152 OK FETCH completed.|
A153 FETCH 166 (BODY.PEEK[1.1])|
* 166 FETCH (BODY[1.1] NIL)|
A153 OK FETCH completed.|
Skipping failed message at index 1 due Error accessing headers due to: No 
contentorg.apache.camel.RuntimeCamelException: Error accessing headers due to: 
No content
        at 
org.apache.camel.component.mail.MailMessage.populateInitialHeaders(MailMessage.java:121)
        at 
org.apache.camel.impl.DefaultMessage.createHeaders(DefaultMessage.java:209)
        at 
org.apache.camel.impl.DefaultMessage.getHeaders(DefaultMessage.java:173)
        at 
org.apache.camel.impl.DefaultMessage.hasHeaders(DefaultMessage.java:190)
        at 
org.apache.camel.impl.DefaultMessage.getHeader(DefaultMessage.java:65)
        at 
com.sap.it.op.agent.collector.camel.MplAccessor.getPropertyFromCxfMessage(MplAccessor.java:334)
        at 
com.sap.it.op.agent.collector.camel.MplAccessor.getMessageProcessingLogFromCxfMessage(MplAccessor.java:324)
        at 
com.sap.it.op.agent.collector.camel.MplAccessor.getMessageProcessingLog(MplAccessor.java:88)
        at 
com.sap.it.op.agent.mpl.factory.adk.impl.AdapterMessageLogFactoryImpl.createNewMplPart(AdapterMessageLogFactoryImpl.java:131)
        at 
com.sap.it.op.agent.mpl.factory.adk.impl.AdapterMessageLogFactoryImpl.getMessageLog(AdapterMessageLogFactoryImpl.java:86)
        at sun.reflect.GeneratedMethodAccessor360.invoke(Unknown Source)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at 
org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)
        at 
org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)
        at com.sun.proxy.$Proxy46.getMessageLog(Unknown Source)
        at 
com.sap.esb.camel.mail.endpoint.configurator.mail.impl.trace.TraceHelper.writeTrace(TraceHelper.java:67)
        at 
com.sap.esb.camel.mail.endpoint.configurator.mail.impl.trace.TraceHelper.writeTraceInbound(TraceHelper.java:58)
        at 
com.sap.esb.camel.mail.endpoint.configurator.mail.impl.trace.TraceMailBindingWithDelegation.extractBodyFromMail(TraceMailBindingWithDelegation.java:47)
        at 
org.apache.camel.component.mail.MailMessage.createBody(MailMessage.java:105)
        at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47)
        at 
org.apache.camel.component.mail.MailConsumer.createExchanges(MailConsumer.java:354)
        at 
org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:128)
        at 
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
        at 
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
        at 
org.apache.camel.pollconsumer.quartz2.QuartzScheduledPollConsumerJob.execute(QuartzScheduledPollConsumerJob.java:61)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at 
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.io.IOException: No content
        at 
javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:115)
        at com.sun.mail.handlers.text_plain.getContent(text_plain.java:80)
        at 
javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:795)
        at javax.activation.DataHandler.getContent(DataHandler.java:542)
        at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:657)
        at 
org.apache.camel.component.mail.MailBinding.extractHeadersFromMail(MailBinding.java:614)
        at 
com.sap.esb.camel.mail.endpoint.configurator.mail.binding.CustomMailBinding.extractHeadersFromMail(CustomMailBinding.java:24)
        at 
com.sap.esb.camel.security.cms.smime.SMimeMailBinding.extractHeadersFromMail(SMimeMailBinding.java:292)
        at 
com.sap.esb.camel.mail.endpoint.configurator.mail.impl.trace.TraceMailBindingWithDelegation.extractHeadersFromMail(TraceMailBindingWithDelegation.java:42)
        at 
org.apache.camel.component.mail.MailMessage.populateInitialHeaders(MailMessage.java:116)
        ... 27 common frames omitted
Caused by: javax.mail.MessagingException: No content
        at 
com.sun.mail.imap.IMAPBodyPart.getContentStream(IMAPBodyPart.java:206)
        at 
javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:99)
        ... 36 common frames omitted

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to