dev@glassfish.java.net

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain with JavaMail and Prelude

From: Lance J. Andersen <Lance.Andersen_at_Sun.COM>
Date: Mon, 10 Nov 2008 18:43:35 -0500

Has anyone seen the following exception using JavaMail and Prelude?
This is from a JavaBean invoked from a JSP.


The basic code looks like:
    -------------------------------------
            Context ctx = new InitialContext();

            String mailHost = (String) ctx.lookup("java:comp/env/mailHost");
            String mailPort = (String) ctx.lookup("java:comp/env/mailPort");
            String mailTo = (String) ctx.lookup("java:comp/env/mailTo");
            String mailProtocol = (String)
ctx.lookup("java:comp/env/mailProtocol");
            String mailPassword = (String)
ctx.lookup("java:comp/env/mailPassword");
            String mailUser = (String) ctx.lookup("java:comp/env/mailUser");

            System.out.println("Mail Host:" + mailHost +
            "\nMail Port:" + mailPort +
            "\nMail User:" + mailUser +
            "\nMail Password:" + mailPassword +
            "\nMail Protocol:" + mailProtocol +
            "\nMail Host:" + mailHost +
            "\nTo:+" + mailTo +
            "\nfrom:+" + emailMsg.getSender());

            Properties props = new Properties();
            props.put("mail." + mailProtocol + ".host", mailHost);
            props.put("mail." + mailProtocol + ".port", mailPort);
            props.put("mail." + mailProtocol + ".auth", "true");
            props.put("mail.debug", "true");
           
            Session session =
                    Session.getDefaultInstance(props);
            session.setDebug(true);

            Transport transport = session.getTransport(mailProtocol);
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(emailMsg.getSender()));

            msg.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse(mailTo, false));

            msg.setSubject("Email from JSP");

           msg.setHeader("X-Mailer", "JavaMail");
            Date timeStamp = new Date();
            msg.setSentDate(timeStamp);
            //msg.setText("hello");
            msg.setContent("hello", "text/plain");
          
            transport.connect(mailHost, mailUser, mailPassword);
            transport.sendMessage(msg, msg.getAllRecipients());
       -------------------------------------

msg.setText("hello") produces the same error.

Regards
Lance

INFO: javax.activation.UnsupportedDataTypeException: no object DCH for
MIME type text/plain
INFO: at
javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:870)
INFO: at javax.activation.DataHandler.writeTo(DataHandler.java:301)
INFO: at
javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
INFO: at
javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745)
INFO: at
com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:636)
INFO: at demo.FeedbackBean.sendMail(FeedbackBean.java:221)
INFO: at demo.FeedbackBean.sendFeedback(FeedbackBean.java:121)
INFO: at
org.apache.jsp.feedbackThanks_jsp._jspService(feedbackThanks_jsp.java
from :69)
INFO: at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
INFO: at
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
INFO: at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
INFO: at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
INFO: at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:366)
INFO: at
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
INFO: at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
INFO: at
org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
INFO: at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
INFO: at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
INFO: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
INFO: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
INFO: at
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
INFO: at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
INFO: at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
INFO: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
INFO: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
INFO: at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
INFO: at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
INFO: at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
INFO: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
INFO: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
INFO: at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
INFO: at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
INFO: at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
INFO: at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
INFO: at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
INFO: at
com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
INFO: at
com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
INFO: at
com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
INFO: at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
INFO: at
com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
INFO: at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
INFO: at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
INFO: at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
INFO: at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
INFO: at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
INFO: at
com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
INFO: at
com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
SEVERE: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
        javax.activation.UnsupportedDataTypeException: no object DCH for
MIME type text/plain
SEVERE: at
com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:676)
SEVERE: at demo.FeedbackBean.sendMail(FeedbackBean.java:221)
SEVERE: at demo.FeedbackBean.sendFeedback(FeedbackBean.java:121)
SEVERE: at
org.apache.jsp.feedbackThanks_jsp._jspService(feedbackThanks_jsp.java
from :69)
SEVERE: at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
SEVERE: at
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
SEVERE: at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
SEVERE: at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
SEVERE: at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:366)
SEVERE: at
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
SEVERE: at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
SEVERE: at
org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
SEVERE: at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
SEVERE: at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
SEVERE: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
SEVERE: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
SEVERE: at
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
SEVERE: at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
SEVERE: at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
SEVERE: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
SEVERE: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
SEVERE: at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
SEVERE: at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
SEVERE: at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
SEVERE: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
SEVERE: at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
SEVERE: at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
SEVERE: at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
SEVERE: at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
SEVERE: at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
SEVERE: at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
SEVERE: at
com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
SEVERE: at
com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
SEVERE: at
com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
SEVERE: at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
SEVERE: at
com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
SEVERE: at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
SEVERE: at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
SEVERE: at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
SEVERE: at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
SEVERE: at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
SEVERE: at
com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
SEVERE: at
com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
SEVERE: Caused by: javax.activation.UnsupportedDataTypeException: no
object DCH for MIME type text/plain
SEVERE: at
javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:870)