Classloader issues in Mendix 5.0.0 with e-mailing

1
In beta versions of Mx 5 there were problems with classloading and sending e-mails was not possible. In mx 5.0.0 those issues still exists, although their not consistent. This kind of exceptions. Any ideas? com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Error sending email at Generiek.VerstuurEmailMicNew (JavaAction : 'Call 'VerstuurEmail'') at Administration.SaveNewPerson (SubMicroflow : 'Call 'VerstuurEmailMicNew'') Advanced stacktrace: at com.mendix.modules.microflowengine.MicroflowUtil.processException(SourceFile:157) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Error sending email at com.mendix.core.component.InternalCore.execute(SourceFile:274) Caused by: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Error sending email at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:217) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Error sending email at com.mendix.jb.a(SourceFile:24) Caused by: com.mendix.core.CoreException: Error sending email at com.mendix.modules.email.Sender.send(SourceFile:88) Caused by: java.security.PrivilegedActionException: null at java.security.AccessController.doPrivileged(Native Method) at com.mendix.modules.email.Sender.sendMessage(SourceFile:165) at com.mendix.modules.email.Sender.send(SourceFile:83) at com.mendix.modules.email.EmailModule$1.b(SourceFile:137) at com.mendix.jb.a(SourceFile:20) at com.mendix.modules.email.EmailModule.mail(SourceFile:131) at generiek.actions.VerstuurEmail.executeAction(VerstuurEmail.java:98) at generiek.actions.VerstuurEmail.executeAction(VerstuurEmail.java:27) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.hq.execute(SourceFile:42) at com.mendix.if.a(SourceFile:44) at com.mendix.ie.a(SourceFile:190) at com.mendix.ie.executeAction(SourceFile:151) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.executeSync(SourceFile:235) at com.mendix.hr.execute(SourceFile:36) at com.mendix.if.a(SourceFile:44) at com.mendix.ie.a(SourceFile:190) at com.mendix.ie.executeAction(SourceFile:151) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.jt.a(SourceFile:135) at com.mendix.pC.a(SourceFile:296) at com.mendix.pC$a.apply$mcI$sp(SourceFile:195) at com.mendix.pC$i.a(SourceFile:211) at com.mendix.pC$i.execute(SourceFile:208) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:132) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) at akka.actor.ActorCell.invoke(ActorCell.scala:456) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) at akka.dispatch.Mailbox.run(Mailbox.scala:219) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: javax.mail.MessagingException: IOException while sending message at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1177) at javax.mail.Transport.send0(Transport.java:195) at javax.mail.Transport.send(Transport.java:124) at com.mendix.modules.email.Sender$1.run(SourceFile:170) at java.security.AccessController.doPrivileged(Native Method) at com.mendix.modules.email.Sender.sendMessage(SourceFile:165) at com.mendix.modules.email.Sender.send(SourceFile:83) at com.mendix.modules.email.EmailModule$1.b(SourceFile:137) at com.mendix.jb.a(SourceFile:20) at com.mendix.modules.email.EmailModule.mail(SourceFile:131) at generiek.actions.VerstuurEmail.executeAction(VerstuurEmail.java:98) at generiek.actions.VerstuurEmail.executeAction(VerstuurEmail.java:27) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.hq.execute(SourceFile:42) at com.mendix.if.a(SourceFile:44) at com.mendix.ie.a(SourceFile:190) at com.mendix.ie.executeAction(SourceFile:151) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.executeSync(SourceFile:235) at com.mendix.hr.execute(SourceFile:36) at com.mendix.if.a(SourceFile:44) at com.mendix.ie.a(SourceFile:190) at com.mendix.ie.executeAction(SourceFile:151) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.jt.a(SourceFile:135) at com.mendix.pC.a(SourceFile:296) at com.mendix.pC$a.apply$mcI$sp(SourceFile:195) at com.mendix.pC$i.a(SourceFile:211) at com.mendix.pC$i.execute(SourceFile:208) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:132) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) at akka.actor.ActorCell.invoke(ActorCell.scala:456) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) at akka.dispatch.Mailbox.run(Mailbox.scala:219) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=Part0_241081031.1392461992136" at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:891) at javax.activation.DataHandler.writeTo(DataHandler.java:317) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1485) at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1773) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1121) at javax.mail.Transport.send0(Transport.java:195) at javax.mail.Transport.send(Transport.java:124) at com.mendix.modules.email.Sender$1.run(SourceFile:170) at java.security.AccessController.doPrivileged(Native Method) at com.mendix.modules.email.Sender.sendMessage(SourceFile:165) at com.mendix.modules.email.Sender.send(SourceFile:83) at com.mendix.modules.email.EmailModule$1.b(SourceFile:137) at com.mendix.jb.a(SourceFile:20) at com.mendix.modules.email.EmailModule.mail(SourceFile:131) at generiek.actions.VerstuurEmail.executeAction(VerstuurEmail.java:98) at generiek.actions.VerstuurEmail.executeAction(VerstuurEmail.java:27) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.hq.execute(SourceFile:42) at com.mendix.if.a(SourceFile:44) at com.mendix.ie.a(SourceFile:190) at com.mendix.ie.executeAction(SourceFile:151) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.executeSync(SourceFile:235) at com.mendix.hr.execute(SourceFile:36) at com.mendix.if.a(SourceFile:44) at com.mendix.ie.a(SourceFile:190) at com.mendix.ie.executeAction(SourceFile:151) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.jt.a(SourceFile:135) at com.mendix.pC.a(SourceFile:296) at com.mendix.pC$a.apply$mcI$sp(SourceFile:195) at com.mendix.pC$i.a(SourceFile:211) at com.mendix.pC$i.execute(SourceFile:208) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:132) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) at akka.actor.ActorCell.invoke(ActorCell.scala:456) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) at akka.dispatch.Mailbox.run(Mailbox.scala:219) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)
asked
4 answers
2

I had a class loader issue with emailing from Mendix 5.1.1 in a proof-of-concept. I put the classloader related statements in comment in method mail in EmailModule.java. After that it seemed to work just fine. Then I got another task and I completely forgot about this. So I have no idea why the code attempted to swap classloaders. The code below is the method as I have it now in the project. Maybe someone else can tell what the code is intended for.

    public static void mail(SMTPConfiguration configuration, String htmlmsg, String plainmsg, String subject, List<String> to, List<String> cc, List<String> bcc, IContext context, List<IMendixObject> attachments) throws CoreException 
    {
        Message message = new Message();
        message.setPlainBody(plainmsg);
        message.setHtmlBody(htmlmsg);

        Sender sender = new Sender(context);
//      Thread currentThread = Thread.currentThread();
//      ClassLoader newClassLoader = Transport.class.getClassLoader();
//      ClassLoader oldClassLoader = currentThread.getContextClassLoader();

        try {
//          currentThread.setContextClassLoader(newClassLoader);
            sender.send(configuration, message, subject, to, cc, bcc, attachments);
        } catch (EmailException e) {
            throw new CoreException("Unable to send email.", e);
        }
        finally
        {
//          currentThread.setContextClassLoader(oldClassLoader);
        }
    }
answered
1

This indeed has something to do with classloaders and should already be solved in the latest versions of the email module.

answered
0

After upgrading to 5.6.0 the e-mail function crashes:

no object DCH for MIME type multipart/mixed; boundary="----=Part9_1848052074.1404549300729"

com.mendix.core.CoreRuntimeException: com.mendix.core.CoreException: Unable to send email. at com.mendix.core.component.InternalCore.execute(SourceFile:271)

I have no idea why this now shows up, it worked before....

answered
0

Any chance that your DCH object is empty or has no content?

answered