rbeckman-nextgen / test-mc4

0 stars 0 forks source link

SMTP Sender is sometimes unable to find mailcap handlers #3023

Open rbeckman-nextgen opened 4 years ago

rbeckman-nextgen commented 4 years ago

We upgraded JavaMail from 1.4.3 to 1.5.0 back in 3.0 RC2 (MIRTH-2841). However, this is now apparently causing SMTP Senders to not work anymore for several people. An error like this gets thrown: \ \ SMTP Sender error ERROR MESSAGE: Error sending email message org.apache.commons.mail.EmailException: Sending the email to the following server failed : 10.10.1.50:25 at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1401) at org.apache.commons.mail.Email.send(Email.java:1428) at com.mirth.connect.connectors.smtp.SmtpDispatcher.send(SmtpDispatcher.java:226) at com.mirth.connect.donkey.server.channel.DestinationConnector.handleSend(DestinationConnector.java:588) at com.mirth.connect.donkey.server.channel.DestinationConnector.process(DestinationConnector.java:336) at com.mirth.connect.donkey.server.channel.DestinationChain.call(DestinationChain.java:224) at com.mirth.connect.donkey.server.channel.Channel.process(Channel.java:1422) at com.mirth.connect.donkey.server.channel.Channel.dispatchRawMessage(Channel.java:955) at com.mirth.connect.donkey.server.channel.SourceConnector.dispatchRawMessage(SourceConnector.java:177) at com.mirth.connect.server.controllers.DonkeyEngineController.dispatchRawMessage(DonkeyEngineController.java:498) at com.mirth.connect.server.controllers.DonkeyMessageController.reprocessMessages(DonkeyMessageController.java:413) at com.mirth.connect.server.servlets.MessageObjectServlet$1.run(MessageObjectServlet.java:166) at java.lang.Thread.run(Thread.java:744) 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_22_262821609.1391196807876" at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1167) at javax.mail.Transport.send0(Transport.java:254) at javax.mail.Transport.send(Transport.java:124) at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1391) ... 12 more Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_22_262821609.1391196807876" at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:891) at javax.activation.DataHandler.writeTo(DataHandler.java:317) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1574) at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1840) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119) ... 15 more

Searching online it appears that some people have had to manually include the JAF activation.jar file to get it to work, even though those classes are included with the JRE anyway (confirmed that the cases seen so far are all using the Sun/Oracle JRE). However even then, it appears to intermittently start/stop working for some people.

Obviously there's some sort of specific scenario in which to reproduce this, because I'm not able to locally. I've also tried to reproduce it from an appliance (CentOS), which matches a client's environment in which the error is occurring.

Forum thread: http://www.mirthcorp.com/community/forums/showthread.php?t=9976

Imported Issue. Original Details: Jira Issue Key: MIRTH-3134 Reporter: narupley Created: 2014-01-31T13:43:24.000-0800

rbeckman-nextgen commented 4 years ago

Still not able to reproduce the issue, on Windows, OSX, or Linux.

Imported Comment. Original Details: Author: narupley Created: 2014-04-14T10:40:52.000-0700

rbeckman-nextgen commented 4 years ago

I've restarted my server 2 days ago and since I have the issue again. I can help in debugging/testing.

Let me know.

Imported Comment. Original Details: Author: lionelroux Created: 2014-04-16T06:36:52.000-0700

rbeckman-nextgen commented 4 years ago

Are you still getting the error even though you've included activation.jar? And are you still getting basically the same stacktrace?

Imported Comment. Original Details: Author: narupley Created: 2014-04-16T07:05:25.000-0700

rbeckman-nextgen commented 4 years ago

No, I rolled back to the default libs in /server-libs and it worked well for weeks.

The stack trace is the same.

I'm going to put the activation lib and restart to see if it changes the behaviour.

Edit : I've just restarted the server without adding any jar in the /server-libs and it works !!!! really odd !

Edit 2: I've restarted once again without any change and it no longer works :)

Imported Comment. Original Details: Author: lionelroux Created: 2014-04-16T07:48:30.000-0700

rbeckman-nextgen commented 4 years ago

So just to confirm, when you originally encountered the issue you fixed it by including activation.jar and restarting the MC server, right? Then you removed activation.jar, restarted the MC server again, and it still worked? But now after restarting a third time it's not working again?

Are you sure you restarted the server after removing that JAR? Because if not, removing the JAR wouldn't have had any affect.

Imported Comment. Original Details: Author: narupley Created: 2014-04-16T07:53:27.000-0700

rbeckman-nextgen commented 4 years ago

yes I confirm I removed the jar file.

Imported Comment. Original Details: Author: lionelroux Created: 2014-04-16T07:55:01.000-0700

rbeckman-nextgen commented 4 years ago

According to this thread:

{quote}Mailcap file search order: The MailcapCommandMap looks in various places in the user's system for mailcap file entries. When requests are made to search for commands in the MailcapCommandMap, it searches mailcap files in the following order:

Back in 3.0 RC2 we upgraded from JavaMail 1.4.3 to 1.5.0. So I checked to see if anything changed. Looking in the manifest for both JARs, they appear to have identical mailcap entries:

`# *

So it doesn't appear that anything should have changed with respect to the JRE being able to lookup handler classes. Can you try adding that mailcap file (with the above contents) in your Java lib folder (whichever JRE your MC server is using) and seeing if that helps?

Another thing you could try is manually adding the entries to the command map, as described here: [https://community.oracle.com/thread/1589225]. You could do this by modifying the actual source code and re-building, but an easier way is just to include that code in a deploy script. You'll have to JavaScript-ify it though:

var mc = javax.activation.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"); javax.activation.CommandMap.setDefaultCommandMap(mc);

Imported Comment. Original Details: Author: narupley Created: 2014-04-16T08:16:49.000-0700

rbeckman-nextgen commented 4 years ago

ok I will try that.

It seems adding or not activation.jar does not change anything. It's not the source of the issue. I'll wait to have the issue once again, and I'll add this deploy script to see if it solves the issue. For now, it works without activation;jar ...

Am I the only one user to be affected by this behaviour ? If yes, it could be my configuration and not a bug.

Imported Comment. Original Details: Author: lionelroux Created: 2014-04-16T08:32:50.000-0700

rbeckman-nextgen commented 4 years ago

Can you also try using Mirth Connect 2.2.3 on that same machine (with the same Java runtime environment), and see if the same thing happens?

Imported Comment. Original Details: Author: narupley Created: 2014-04-20T08:13:00.000-0700

rbeckman-nextgen commented 4 years ago

I did some tests with the last 2.X version. No problem occured.

Since my last message, no more problem on my 3.0.1 production instance. I think we should close this ticket.

Imported Comment. Original Details: Author: lionelroux Created: 2014-05-13T05:09:00.000-0700

rbeckman-nextgen commented 4 years ago

I'll keep it open for now, only because you're not the only person that has encountered this. However, we're still not sure if it necessarily has to do with 3.x (or the updated JavaMail library), or if it's some kind of general Java bug / configuration error. From what others have reported this appears to occur only after the server restarts, but it's seemingly random.

Imported Comment. Original Details: Author: narupley Created: 2014-05-13T05:53:02.000-0700

rbeckman-nextgen commented 4 years ago

By the way, I just upgraded to 3.0.2 10 minutes ago, I did a quick test with an old message and no problem occurs.

Imported Comment. Original Details: Author: lionelroux Created: 2014-05-13T09:06:08.000-0700

rbeckman-nextgen commented 4 years ago

Our linux Mirth Server somehow loses it's ability to send emails over the weekend. If I restart the Mirth Server than it all works fine again. Our database and also mail server have a shutdown period during the weekend and this is while Mirth is still running. Maybe that will help resolve the issue.

Imported Comment. Original Details: Author: stickybandit Created: 2014-06-17T08:29:10.000-0700

rbeckman-nextgen commented 4 years ago

Since the error message says... 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_7_597826273.1402937805134" at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTr ansport.java:1167) at javax.mail.Transport.send0(Transport.java:254) at javax.mail.Transport.send(Transport.java:124) at org.apache.commons.mail.Email.sendMimeMessage(Emai l.java:1391) ... 15 more

It looks like you are using apache.commons.mail I would get rid of this apache stuff and just use the J2EE java.mail package from Sun(Oracle).
I have used mail in many enterprise java projects and never had this problem.

Imported Comment. Original Details: Author: stickybandit Created: 2014-06-17T08:33:16.000-0700

rbeckman-nextgen commented 4 years ago

Hello All,

So I am receiving this issue on my local machine. I looked through the comments and it doesn't seem like there is a workaround yet. Am I missing something?

Thanks, Zak

Imported Comment. Original Details: Author: zfjeldhe Created: 2014-10-28T13:52:56.000-0700

rbeckman-nextgen commented 4 years ago

What version of Mirth Connect were you having the issue with Zachary?

Imported Comment. Original Details: Author: wayneh Created: 2014-12-18T13:31:05.000-0800

rbeckman-nextgen commented 4 years ago

The problem is only occurring under a certain condition for me. When an alert sends to a channel and the channel uses SMTP sender I get "javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed". If I use a channel to send to a channel the SMTP sender works fine.

How does an alert sending to a channel work differently then a channel sending to a channel? Are there possible class-path or environment differences when an alert is triggered?

Imported Comment. Original Details: Author: mickeycdawg Created: 2015-03-09T09:15:15.000-0700

rbeckman-nextgen commented 4 years ago

I am using Mirth Connect 3.4.1.8057 with java build 1.8.0_102-b14 on RHEL linux server and I have the exact same problem as [~mickeycdawg]:

When a (custom alerts.sendAlert(message)) alert sends its data to channel, that same channels SMTP Sender destination throws this error: SMTP Sender error ERROR MESSAGE: Error sending email message org.apache.commons.mail.EmailException: Sending the email to the following server failed : {SMTP_SERVER_HOSTNAME}:25 at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1401) at org.apache.commons.mail.Email.send(Email.java:1428) at com.mirth.connect.connectors.smtp.SmtpDispatcher.send(SmtpDispatcher.java:248) at com.mirth.connect.donkey.server.channel.DestinationConnector.handleSend(DestinationConnector.java:778) at com.mirth.connect.donkey.server.channel.DestinationConnector.process(DestinationConnector.java:437) at com.mirth.connect.donkey.server.channel.DestinationChain.doCall(DestinationChain.java:121) at com.mirth.connect.donkey.server.channel.DestinationChain.call(DestinationChain.java:63) at com.mirth.connect.donkey.server.channel.Channel.process(Channel.java:1706) at com.mirth.connect.donkey.server.channel.Channel.dispatchRawMessage(Channel.java:1189) at com.mirth.connect.donkey.server.channel.SourceConnector.dispatchRawMessage(SourceConnector.java:192) at com.mirth.connect.server.controllers.DonkeyEngineController.dispatchRawMessage(DonkeyEngineController.java:1053) at com.mirth.connect.server.alert.action.ChannelProtocol.doCustomDispatch(ChannelProtocol.java:54) at com.mirth.connect.server.alert.AlertWorker$ActionTask.call(AlertWorker.java:168) at com.mirth.connect.server.alert.AlertWorker$ActionTask.call(AlertWorker.java:97) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 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_88_19926851.1479912678355" at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1167) at javax.mail.Transport.send0(Transport.java:254) at javax.mail.Transport.send(Transport.java:124) at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1391) ... 17 more Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_88_19926851.1479912678355" at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source) at javax.activation.DataHandler.writeTo(Unknown Source) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1574) at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1840) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119) ... 20 more

But if I reprocess the message, it sends email just fine.

I tried with workaround: var mc = javax.activation.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"); javax.activation.CommandMap.setDefaultCommandMap(mc); but to no avail.

Edit: I solved the problem by sending email alerts directly with alerts system and I left the channel for ELK stack only.

Imported Comment. Original Details: Author: bratwurzt Created: 2016-11-23T07:06:38.000-0800