我遇到了一个问题,这里已经多次报道,但到目前为止还没有任何解决方案帮助我。
路线相当简单。它等待具有特定主题的电子邮件,从邮件中的参数创建PDF并将此PDF邮寄回发件人。
当我在Eclipse中作为Junit测试用例启动路径时,它就像一个魅力,但在Linux服务器上的Tomcat中运行它会崩溃" javax.mail.MessagingException:缺少起始边界"当它尝试发送包含PDF附件的电子邮件时。
*)本地测试环境: Tomcat 8.0.5,Windows 7,Java 1.8.0_20,Camel 2.14.0
*)服务器环境: Tomcat 8.0.12,Ubuntu Server 14.0.1。 LTS,Java 1.8.0_20,Camel 2.14.0
*)我已尝试过什么: - 使用较新版本的mail.jar(通过升级到当前的Camel版本) - 将mail.jar,activation.jar放入Tomcat lib - 设置各种mail.mime.multipart.XXX属性 所有版本和组合都不同=>没有成功。
在路由代码,处理器和堆栈跟踪之下。实际上在这条路线上没什么了不起的......
任何想法???
路线:
from("imap://XXXXXXXXXXXXXXXX?" +
"host=XXXXXXXXXXXXXXXXX&" +
"password=XXXXXXXXXX&" +
"delete=true&" +
"consumer.delay=12000&" +
"searchTerm.subjectOrBody=XXXXXXXXXXXXXXXXX&" +
"searchTerm.unseen=true"
)
.routeId(ROUTE_ID)
.process(attachmentProcessor)
.setHeader("to", simple("${in.header.from}"))
.setHeader("from", simple("XXXXXXXXXXXXXXXXX"))
.setHeader("subject", simple("XXXXXXXXXXXXXXXXX"))
.setBody(simple("XXXXXXXXXXXXXXXX"))
.to("smtp://XXXXXXXXXXXXXXXXX")
.log(mailMessage);
;
处理器的一部分:
pdfUtil.generateLabels(tempDirPath, year, sequenceNumberStart, numberOfPages);
exchange.getIn().addAttachment(fileName, new DataHandler(new FileDataSource(tempDirPath)));
可怕的例外......: - (
javax.mail.MessagingException: Missing start boundary
at javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:882)
at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:503)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:417)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1354)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:419)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1354)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2107)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2075)
at org.apache.camel.component.mail.DefaultJavaMailSender.send(DefaultJavaMailSender.java:118)
at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:56)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:143)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:307)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:138)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
at org.apache.camel.component.mail.MailConsumer.processExchange(MailConsumer.java:287)
at org.apache.camel.component.mail.MailConsumer.processBatch(MailConsumer.java:213)
at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:119)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:1)
可能的解决方案:
请参阅Missing start boundary Exception when reading messages with an attachment file。解决方案建议设置属性mail.mime.multipart.ignoreexistingboundaryparameter
:
System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true");
我希望它有所帮助。
答案 1 :(得分:1)
我遇到了这个问题。该问题是由在交换机上的In消息(边界,mime类型等)上设置的入站imap标头引起的,当您尝试发送邮件时,这会使SMTP服务器混淆。
在attachmentProcessor
中使用Out
消息代替in
生成的正文。这会创建一条新消息,从组件
例如:
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("here's the resulting message");
}
})