camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Exception thrown when reading a mail with an attached file, which name contains a semicolon
Date Thu, 03 Sep 2015 14:34:35 GMT
Hi

Can you try with sun java mail instead of ibm? Maybe from an unit test.

Also using semi colons in file names is not such a good idea. as afair
semi colon is used in some headers to separate multi values, eg
content-type=xml; charset=utf-8

You can enable debug option on the mail component and see what all
those headers are and see if you can spot the one with the file name
with semi colon and see what its actual value is.

You can also try to turn of mapMailMessage=false and do you own parsing.



On Mon, Aug 24, 2015 at 4:00 PM, Thierry Frossard
<tfrossard@groupemutuel.ch> wrote:
> Hi,
>
> I'm using Camel 2.15.2 with JDK 1.7 under Windows 7 and Eclipse 4.2.2 as
> development tool.
>
> My route reads from an IMAP server (IBM Lotus Notes). I have one big problem
> : when the route handles an email, which contains an attached file with a
> semicolon in his name, then the route always throws this exception :
>
> Failed to extract body due to: Unable to load BODYSTRUCTURE.
>
> 4.08.15 15:10:11:313 CEST] 00000172 SystemOut     O [15:10:11.313] WARN
> [Camel (Mail vers Indexation) thread #0 - imap://gmain2p01.groupemutuel.ch]
> org.apache.camel.util.CamelLogger.log:224 : Caused by:
> [org.apache.camel.RuntimeCamelException - Failed to extract body due to:
> Unable to load BODYSTRUCTURE. Exchange: Exchange[MailMessage@0x862446e3].
> Message: com.sun.mail.imap.IMAPMessage@16e6c70e]
> org.apache.camel.RuntimeCamelException: Failed to extract body due to:
> Unable to load BODYSTRUCTURE. Exchange: Exchange[MailMessage@0x862446e3].
> Message: com.sun.mail.imap.IMAPMessage@16e6c70e
>         at
> org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:275)
> ~[camel-mail-2.15.2.jar:2.15.2]
>         at
> org.apache.camel.component.mail.MailMessage.createBody(MailMessage.java:103)
> ~[camel-mail-2.15.2.jar:2.15.2]
>         at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:41)
> ~[camel-core-2.15.2.jar:2.15.2]
>         at
> org.apache.camel.component.mail.MailConsumer.createExchanges(MailConsumer.java:326)
> ~[camel-mail-2.15.2.jar:2.15.2]
>         at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:121)
> ~[camel-mail-2.15.2.jar:2.15.2]
>         at
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
> [camel-core-2.15.2.jar:2.15.2]
>         at
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
> [camel-core-2.15.2.jar:2.15.2]
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:482)
> [na:1.7.0]
>         at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:315)
> [na:1.7.0]
>         at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:189)
> [na:1.7.0]
>         at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
> [na:1.7.0]
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
> [na:1.7.0]
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626)
> [na:1.7.0]
>         at java.lang.Thread.run(Thread.java:804) [na:1.7.0]
> Caused by: javax.mail.MessagingException: Unable to load BODYSTRUCTURE
>         at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1261)
> ~[com.ibm.ws.prereq.javamail.jar:na]
>         at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:597)
> ~[com.ibm.ws.prereq.javamail.jar:na]
>         at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1395)
> ~[com.ibm.ws.prereq.javamail.jar:na]
>         at
> org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:247)
> ~[camel-mail-2.15.2.jar:2.15.2]
>         ... 13 common frames omitted
>
> Here is the route (very simple) :
>
>   @Override
>   public void configure() throws Exception {
>     from(getPropertiesUri())
>     /**/.to("log:dummy");
>   }
>
>   protected String getPropertiesUri() {
>     String prefix = Constants.MAIL.concat(provider);
>     StringBuilder uri = new StringBuilder();
>
>
> uri.append(getContext().getProperties().get(prefix.concat(".protocol"))).append("://");
>
> uri.append(getContext().getProperties().get(prefix.concat(".host"))).append("?");
>
> uri.append("username=").append(getContext().getProperties().get(prefix.concat(".user")));
>
> uri.append("&password=").append(getContext().getProperties().get(prefix.concat(".password")));
>
> uri.append("&folderName=").append(getContext().getProperties().get(prefix.concat(".folder")));
>
> uri.append("&unseen=").append(getContext().getProperties().get(prefix.concat(".unseen")));
>
> uri.append("&consumer.delay=").append(getContext().getProperties().get(prefix.concat(".consuming.delay")));
>
> uri.append("&delete=").append(getContext().getProperties().get(prefix.concat(".delete")));
>
>     String options =
> getContext().getProperties().get(prefix.concat(".options"));
>
>     if (StringUtils.isNotBlank(options)) {
>
> uri.append("&").append(getContext().getProperties().get(prefix.concat(".options")));
>     }
>
>     return uri.toString();
>   }
>
> and the uri used to retrieve the mail :
>
> imap://gmain2p01.groupemutuel.ch?username=username&password=password&folderName=IMAP&unseen=true&consumer.delay=30000&delete=true
>
> I didn't find anywhere a similar problem with Camel mail component so I
> don't know if it's a bug or if I'm doing something wrong.
>
> Kind regards and thanks a lot for helping.
>
> Thierry Frossard
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-thrown-when-reading-a-mail-with-an-attached-file-which-name-contains-a-semicolon-tp5770941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2

Mime
View raw message