Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
Unknown
Description
ClassCastException: class org.apache.camel.component.directvm.DirectVmEndpoint cannot be cast to class org.apache.camel.component.mail.MailEndpoint
This is caused by:
MailConfiguration mailConfiguration = ((MailEndpoint) exchange.getFromEndpoint()).getConfiguration();
Which assumes the exchanges endpoint is always a MailEndpoint.
This piece of code from DefaultUnitOfWork will trigger the init of headers:
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); } }
If message is of type MailMessage, it will be delegated there:
MailBinding binding = ExchangeHelper.getBinding(getExchange(), MailBinding.class); if (binding != null) { map.putAll(binding.extractHeadersFromMail(mailMessage, getExchange())); }
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.