[ 
https://issues.apache.org/jira/browse/CAMEL-16878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17402077#comment-17402077
 ] 

Claus Ibsen commented on CAMEL-16878:
-------------------------------------

What version of Camel are you using?

> using breadcrumbs can cause ClassCastException in MailBinding
> -------------------------------------------------------------
>
>                 Key: CAMEL-16878
>                 URL: https://issues.apache.org/jira/browse/CAMEL-16878
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>            Reporter: Rik van Ballegooijen
>            Priority: Major
>
> ClassCastException: class 
> org.apache.camel.component.directvm.DirectVmEndpoint cannot be cast to class 
> org.apache.camel.component.mail.MailEndpoint
>  
> This is caused by:
>  
> {code:java}
> MailConfiguration mailConfiguration = ((MailEndpoint) 
> exchange.getFromEndpoint()).getConfiguration();{code}
> Which assumes the exchanges endpoint is always a MailEndpoint.
>  
> This piece of code from DefaultUnitOfWork will trigger the init of headers:
> {code:java}
> if (useBreadcrumb) {
>     // create or use existing breadcrumb
>     String breadcrumbId = exchange.getIn().getHeader(Exchange.BREADCRUMB_ID, 
> String.class);
>     if (breadcrumbId == null) {
>         // no existing breadcrumb, so create a new one based on the exchange 
> id
>         breadcrumbId = exchange.getExchangeId();
>         exchange.getIn().setHeader(Exchange.BREADCRUMB_ID, breadcrumbId);
>     }
> }
> {code}
> If message is of type MailMessage, it will be delegated there:
> {code:java}
> MailBinding binding = ExchangeHelper.getBinding(getExchange(), 
> MailBinding.class);
> if (binding != null) {
>     map.putAll(binding.extractHeadersFromMail(mailMessage, getExchange()));
> }
> {code}
> This works for the initial route with a from imaps, but in a subroute the 
> error occurs.
>  
> Possible solution could be to pass a reference to either the mail endpoint or 
> mail configuration to the binding on create/set.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to