Send mail failed with "UnsupportedDataTypeException"

ES log:

[2015-10-28 19:01:01,161][ERROR][watcher.actions.email    ] [crawler_service_001] failed to execute action [error-watch/alert_email]
javax.mail.MessagingException: failed to send email with subject [some error] via account [u51_account];
  nested exception is:
	javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_24_355222995.1446030060989"
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:85)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:77)
	at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:67)
	at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:106)
	at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:381)
	at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:273)
	at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:419)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_24_355222995.1446030060989"
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1245)
	at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:109)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:83)
	... 9 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_24_355222995.1446030060989"
	at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:896)
	at javax.activation.DataHandler.writeTo(DataHandler.java:317)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1627)
	at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1849)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1196)
	... 11 more

The code to build email action:

EmailTemplate.Builder emailBuilder = EmailTemplate.builder();
emailBuilder.to(receivers);
emailBuilder.subject(subject);
String bodyTemplate = ResourceUtils.readResourceToString("error-message-email-body-template.html");
emailBuilder.htmlBody(bodyTemplate);
EmailAction.Builder emailActionBuilder = EmailAction.builder(emailBuilder.build());
emailActionBuilder.setAttachPayload(DataAttachment.YAML);
return emailActionBuilder;

Both ES and watcher are 2.0.0-rc1.

We've just released the GAs for ES and Watcher 2.0, have you tried with those?

Thanks your advice but I upgrade both elasticsearch and watcher to 2.0.0(without rc1, sure), it still gives:

[2015-10-29 16:25:02,004][ERROR][watcher.actions.email    ] [crawler_service_001] failed to execute action [error-watch/alert_email]
javax.mail.MessagingException: failed to send email with subject [errors encountered!] via account [u51_account];
  nested exception is:
	javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_4_1547992646.1446107101838"
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:85)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:77)
	at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:67)
	at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:106)
	at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:381)
	at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:274)
	at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:419)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_4_1547992646.1446107101838"
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1245)
	at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:109)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:83)
	... 9 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_4_1547992646.1446107101838"
	at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:896)
	at javax.activation.DataHandler.writeTo(DataHandler.java:317)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1627)
	at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1849)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1196)
	... 11 more

@warkolm @spinscale

I find that error always occurs despite of which type(JSON or YAML) of attachment of the mail. Even no attachment still encountered that error.

I google about that, some guys say that the cause of that problem is the version of java mail library. But as you know, Watcher is not a open source plugin, so it's hard for me to figure out what goes wrong in mail module of Watcher.

I Upgraded Watcher and ES to 2.0.0-rc1(then 2.0.0 after GA released) on Monday , but just couldn't send a mail successfully up to now, this Friday. I'm under a lot of stress because a team waiting this feature for a week. I can't roll back ES to 1.7 because another team wants Kibana 4.2.0(custom name for filter, a great feature) badly.

Really looking-forward a reply from you official guys.

@spinscale

Look at what they suggested in this thread: UnsupportedDataTypeException when trying to send email

This worked for me on the latest watcher, and ES 2.0.0 Stable:

    $ cd /usr/share/elasticsearch/plugins/watcher/
    $ sudo mv activation-1.1.1.jar ../../lib/
    $ sudo mv javax.mail-1.5.3.jar ../../lib/
    $ sudo service elasticsearch restart

1 Like

@kurtcoke Thanks for the concise workaround. I have faced this on a Windows environment ES 2.0 GA, and the workaround was very useful.

simply AWESOME! thanks a lot

Hey,

just a quick heads up. This is fixed in Elasticsearch 2.0.2 and 2.1.1 and does not require any workarounds any more.

--Alex