在 Transport.send(message) 上获取 ParseException

发布于 2024-10-19 22:43:02 字数 16590 浏览 7 评论 0原文

由于某种原因,当我在 MimeMessage 上调用 Transport.send() 时,出现 javax.mail.internet.ParseException 。以前,当它只是一封纯文本电子邮件时,这是有效的,但是当我将其更改为同时包含文本和 html 时,它开始爆炸。有什么想法我做错了吗?

@Resource(mappedName = "java:/Mail")
    private Session mailer;

    public void sendMessage(String toEmailAddress, String subject, String content, String text) throws Exception {
        try {
            Message message = new MimeMessage(mailer);

            MimeMultipart rootMixedMultipart = new MimeMultipart("mixed");
            message.setContent(rootMixedMultipart);

            MimeMultipart nestedRelatedMultipart = new MimeMultipart("related");
            MimeBodyPart relatedBodyPart = new MimeBodyPart();
            relatedBodyPart.setContent(nestedRelatedMultipart);
            rootMixedMultipart.addBodyPart(relatedBodyPart);

            MimeMultipart messageBody = new MimeMultipart("alternative");
            MimeBodyPart bodyPart = null;
            for (int i = 0; i < nestedRelatedMultipart.getCount(); i++) {
                BodyPart bp = nestedRelatedMultipart.getBodyPart(i);
                if (bp.getFileName() == null) {
                    bodyPart = (MimeBodyPart) bp;
                }
            }
            if (bodyPart == null) {
                MimeBodyPart mimeBodyPart = new MimeBodyPart();
                nestedRelatedMultipart.addBodyPart(mimeBodyPart);
                bodyPart = mimeBodyPart;
            }
            bodyPart.setContent(messageBody, "text/alternative");

            // Create the plain text part of the message.
            MimeBodyPart plainTextPart = new MimeBodyPart();
            plainTextPart.setText(text, "UTF-8");
            messageBody.addBodyPart(plainTextPart);

            // Create the HTML text part of the message.
            MimeBodyPart htmlTextPart = new MimeBodyPart();
            htmlTextPart.setContent(content, "CONTENT_TYPE_HTML;charset=UTF-8");
            messageBody.addBodyPart(htmlTextPart);

            message.setFrom(new InternetAddress(NO_REPLY_EMAIL_ADDRESS, PERSONAL));
            message.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmailAddress));
            message.setSubject(subject);
            message.setHeader("Precedence", "bulk");
            Transport.send(message);
        }
        catch (Exception e) {
        }
    }

这是堆栈跟踪。

2011-03-03 00:20:05,896 ERROR [STDERR] javax.mail.internet.ParseException
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.ContentType.<init>(ContentType.java:89)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1249)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2012)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1980)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.Transport.send(Transport.java:97)
2011-03-03 00:20:05,897 ERROR [STDERR]  at com.lawless.manager.NotificationManagerBean.sendMessage(NotificationManagerBean.java:69)
2011-03-03 00:20:05,897 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,897 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,897 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,897 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
2011-03-03 00:20:05,898 ERROR [STDERR]  at $Proxy97.sendMessage(Unknown Source)
2011-03-03 00:20:05,898 ERROR [STDERR]  at com.lawless.manager.CommentManagerBean.sendCommentNotification(CommentManagerBean.java:85)
2011-03-03 00:20:05,898 ERROR [STDERR]  at com.lawless.manager.CommentManagerBean.addComment(CommentManagerBean.java:44)
2011-03-03 00:20:05,898 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,899 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,899 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,899 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
2011-03-03 00:20:05,900 ERROR [STDERR]  at $Proxy100.addComment(Unknown Source)
2011-03-03 00:20:05,900 ERROR [STDERR]  at com.lawless.web.ListingAction.addComment(ListingAction.java:97)
2011-03-03 00:20:05,900 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,900 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,900 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,900 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,900 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442)
2011-03-03 00:20:05,900 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.stripesstuff.plugin.security.SecurityInterceptor.interceptEventHandling(SecurityInterceptor.java:188)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.stripesstuff.plugin.security.SecurityInterceptor.intercept(SecurityInterceptor.java:120)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:278)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:160)
2011-03-03 00:20:05,901 ERROR [STDERR]  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DynamicMappingFilter$2.doFilter(DynamicMappingFilter.java:364)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:351)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2011-03-03 00:20:05,902 ERROR [STDERR]  at java.lang.Thread.run(Thread.java:619)

For some reason I'm getting a javax.mail.internet.ParseException when I call Transport.send() on a MimeMessage. This worked before when it was only a plain text email, but when I changed it to have both text and html it started blowing up. Any ideas what I'm doing wrong?

@Resource(mappedName = "java:/Mail")
    private Session mailer;

    public void sendMessage(String toEmailAddress, String subject, String content, String text) throws Exception {
        try {
            Message message = new MimeMessage(mailer);

            MimeMultipart rootMixedMultipart = new MimeMultipart("mixed");
            message.setContent(rootMixedMultipart);

            MimeMultipart nestedRelatedMultipart = new MimeMultipart("related");
            MimeBodyPart relatedBodyPart = new MimeBodyPart();
            relatedBodyPart.setContent(nestedRelatedMultipart);
            rootMixedMultipart.addBodyPart(relatedBodyPart);

            MimeMultipart messageBody = new MimeMultipart("alternative");
            MimeBodyPart bodyPart = null;
            for (int i = 0; i < nestedRelatedMultipart.getCount(); i++) {
                BodyPart bp = nestedRelatedMultipart.getBodyPart(i);
                if (bp.getFileName() == null) {
                    bodyPart = (MimeBodyPart) bp;
                }
            }
            if (bodyPart == null) {
                MimeBodyPart mimeBodyPart = new MimeBodyPart();
                nestedRelatedMultipart.addBodyPart(mimeBodyPart);
                bodyPart = mimeBodyPart;
            }
            bodyPart.setContent(messageBody, "text/alternative");

            // Create the plain text part of the message.
            MimeBodyPart plainTextPart = new MimeBodyPart();
            plainTextPart.setText(text, "UTF-8");
            messageBody.addBodyPart(plainTextPart);

            // Create the HTML text part of the message.
            MimeBodyPart htmlTextPart = new MimeBodyPart();
            htmlTextPart.setContent(content, "CONTENT_TYPE_HTML;charset=UTF-8");
            messageBody.addBodyPart(htmlTextPart);

            message.setFrom(new InternetAddress(NO_REPLY_EMAIL_ADDRESS, PERSONAL));
            message.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmailAddress));
            message.setSubject(subject);
            message.setHeader("Precedence", "bulk");
            Transport.send(message);
        }
        catch (Exception e) {
        }
    }

Here's the stack trace.

2011-03-03 00:20:05,896 ERROR [STDERR] javax.mail.internet.ParseException
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.ContentType.<init>(ContentType.java:89)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1249)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1001)
2011-03-03 00:20:05,896 ERROR [STDERR]  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:333)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1255)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2012)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1980)
2011-03-03 00:20:05,897 ERROR [STDERR]  at javax.mail.Transport.send(Transport.java:97)
2011-03-03 00:20:05,897 ERROR [STDERR]  at com.lawless.manager.NotificationManagerBean.sendMessage(NotificationManagerBean.java:69)
2011-03-03 00:20:05,897 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,897 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,897 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,897 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
2011-03-03 00:20:05,897 ERROR [STDERR]  at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
2011-03-03 00:20:05,898 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
2011-03-03 00:20:05,898 ERROR [STDERR]  at $Proxy97.sendMessage(Unknown Source)
2011-03-03 00:20:05,898 ERROR [STDERR]  at com.lawless.manager.CommentManagerBean.sendCommentNotification(CommentManagerBean.java:85)
2011-03-03 00:20:05,898 ERROR [STDERR]  at com.lawless.manager.CommentManagerBean.addComment(CommentManagerBean.java:44)
2011-03-03 00:20:05,898 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,899 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,899 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,899 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,899 ERROR [STDERR]  at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
2011-03-03 00:20:05,900 ERROR [STDERR]  at $Proxy100.addComment(Unknown Source)
2011-03-03 00:20:05,900 ERROR [STDERR]  at com.lawless.web.ListingAction.addComment(ListingAction.java:97)
2011-03-03 00:20:05,900 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2011-03-03 00:20:05,900 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2011-03-03 00:20:05,900 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2011-03-03 00:20:05,900 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:597)
2011-03-03 00:20:05,900 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442)
2011-03-03 00:20:05,900 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.stripesstuff.plugin.security.SecurityInterceptor.interceptEventHandling(SecurityInterceptor.java:188)
2011-03-03 00:20:05,900 ERROR [STDERR]  at org.stripesstuff.plugin.security.SecurityInterceptor.intercept(SecurityInterceptor.java:120)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:278)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:160)
2011-03-03 00:20:05,901 ERROR [STDERR]  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DynamicMappingFilter$2.doFilter(DynamicMappingFilter.java:364)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
2011-03-03 00:20:05,901 ERROR [STDERR]  at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:351)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2011-03-03 00:20:05,901 ERROR [STDERR]  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2011-03-03 00:20:05,902 ERROR [STDERR]  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2011-03-03 00:20:05,902 ERROR [STDERR]  at java.lang.Thread.run(Thread.java:619)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无可置疑 2024-10-26 22:43:02

查看

htmlTextPart.setContent(content, "CONTENT_TYPE_HTML;charset=UTF-8");

您想要引用 CONTENT_TYPE_HTML 的位置,但将字符串放入 contenttype 参数中。 CONTENT_TYPE_HTML 当然不是有效的内容类型声明。 CONTENT_TYPE_HTML 可能是“SomeClass”的静态最终字符串成员,我猜它等于“text/html”。

而是使用

htmlTextPart.setContent(content, SomeClass.CONTENT_TYPE_HTML+";charset=UTF-8");

将内容类型设置为 text/html;charset=utf-8。当然,将 SomeClass 替换为定义成员 CONTENT_TYPE_HTML 的真实类。

Look at

htmlTextPart.setContent(content, "CONTENT_TYPE_HTML;charset=UTF-8");

where you want to reference to a CONTENT_TYPE_HTML, but put is a String into the contenttype parameter. CONTENT_TYPE_HTML is of course not a valid content-type declaration. CONTENT_TYPE_HTML is probably a static final String member of "SomeClass", which equals "text/html", I guess.

Instead use

htmlTextPart.setContent(content, SomeClass.CONTENT_TYPE_HTML+";charset=UTF-8");

to set the content-type to text/html;charset=utf-8. Of course replace SomeClass with the real class where the member CONTENT_TYPE_HTML was defined.

只是我以为 2024-10-26 22:43:02

尝试使用以下内容,
Email.setContent(Object o, String contentType)

try using the following,
Email.setContent(Object o, String contentType)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文