-1

I have a random error with my web app in Struts2 when java code send a mail:

javax.mail.MessagingException: IOException while sending message;
  nested exception is:
    javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1290)
    at javax.mail.Transport.send0(Transport.java:255)
    at javax.mail.Transport.send(Transport.java:124)

I have deployed file war in WILDFLY 10 (Jdk 1.8) and inside war in folder WEB-INF/lib there are these libraries: activation-1.1.jar and mail-1.4.jar.

Sometimes sending the email works but random I see the error above. All emails have no attachments and the code is always the same.

I am going crazy, I'm doing email test in Test environment and it always works.

I checked folder "modules/system/layers/base/javax/mail/api/main" in Wildfly and founded "javax.mail-1.5.5.jar", in "/modules/system/layers/base/javax/activation/api/main" there is "activation-1.1.1.jar"

Any idea? thank a lots

2 Answers2

1

I founded solution before send email with this code

MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); 
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); 
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); 
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); 
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); 
mc.addMailcap("message/rfc822;; x-java-content- handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);

thanks

alexrnov
  • 2,346
  • 3
  • 18
  • 34
0

Add this part of code before sending mail in your code:

Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );