缺少开始边界异常Tomcat中有附件文件发送邮件时 [英] Missing start boundary Exception when sending messages with an attachment file in Tomcat

查看:959
本文介绍了缺少开始边界异常Tomcat中有附件文件发送邮件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些可能的匹配到为我工作这个问题,但没有。

I've found a number of possible matches to this problem but none that work for me.

我使用Apache的骆驼提供一个文件作为电子邮件attachement。它完美使用下面的Maven目标:

I'm using Apache Camel to deliver a file as an email attachement. It works perfectly using the following maven goals:

码头:运行
码头:运行爆炸
码头:运行战争

jetty:run jetty:run-exploded jetty:run-war

我使用的Java 1.6。我的部署容器是的tomcat6。在tomcat6中和tomcat7我得到了以下异常:

I'm using java 1.6. My deployment container is tomcat6. In tomcat6 and tomcat7 I get the following exception:

org.springframework.mail.MailSendException:失败的消息:javax.mail.MessagingException的:缺少开始边界;消息异常详细信息(1):
失败的消息1:
javax.mail.MessagingException的:缺少开始边界
在javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:882)

org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: Missing start boundary; message exception details (1) are: Failed message 1: javax.mail.MessagingException: Missing start boundary at javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:882)

在网络上的意见认为这是一个类加载器的问题。它要么激活-1.1.jar或邮件1.4.4.jar文件不被发现,或邮件1.4.4.jar的mailcap文件不被发现。

The advice on the web suggests this is a class loader problem. Its either that the activation-1.1.jar or mail-1.4.4.jar files are not being found, or the mailcap file in mail-1.4.4.jar is not being found.

我试图把到Tomcat / lib中这些JAR文件。我试着从复制的jar文件中的mailcap进入爆发战争的META-INF目录。这些都不有所作为。

I've tried putting these jar files in tomcat/lib. I've tried copying the mailcap from the jar file into the META-INF directory of the exploded war. Neither of these make a difference.

版本:

Windows系统:的Apache Tomcat / 7.0.5 JDK 1.6.0_27-B07 Apache的骆驼2.8.0熔丝-00-08

Windows: Apache Tomcat/7.0.5 JDK 1.6.0_27-b07 Apache Camel 2.8.0-fuse-00-08

Linux的 - 随之而来的Ubuntu 10.04 LTS版本 - 以后我会检查这些,并添加

Linux - the versions that come with ubuntu 10.04 LTS - I'll check these later and add.

这是我的骆驼路线的简化版本:

This is a simplified version of my camel routes:

<route id="uploadFileForm">
    <from uri="jetty:http://0.0.0.0:9095/premier"/>
    <to uri="velocity:form.html"/>
</route>
<route id="uploadFile">
    <from uri="jetty:http://0.0.0.0:9095/fup"/>
    <to uri="log:mail?showBody=true&amp;showHeaders=true"/>
    <to uri="smtp://localhost"/>
    <setHeader headerName="content-type"><constant>text/plain</constant></setHeader>
    <setBody><constant>Message Sent</constant></setBody>
</route>

这是什么日志显示:

[4 - seda://mail-ws-audio-files] mail                           INFO  Exchange[ExchangePattern:InOut, Headers:{Connection=Keep-Alive, CamelHttpServletRequest=org.eclipse.jetty.servlets.MultiPartFilter$Wrapper@bb32c5, upfile=D:downloads!37SQFTS.pdf, CamelHttpPath=/fup, subject=BBC Premier League Update - Edition 1, CamelHttpQuery=null, CamelHttpServletResponse=HTTP/1.1 200 

, UntilMessage=until 10:30 GMT when a second bulletin is available (Mon-Fri only), Host=localhost:9095, User-Agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E), Accept-Encoding=gzip, deflate, bulletin_type=am, to=julian.cable@yahoo.com, cc=admin@localhost, breadcrumbId=ID-B1-L0N336601-58958-1335935026761-0-2, CamelHttpUrl=http://localhost:9095/fup, Content-Length=24896, Referer=http://localhost:9095/premier, from=jfbcable@gmail.com, Accept=image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*, Accept-Language=en-GB, Content-Type=multipart/form-data; boundary=---------------------------7dc3a8371906f6, CamelHttpUri=/fup, Cache-Control=no-cache, CamelHttpMethod=POST}, BodyType:String, Body:Dear Partner,

    please find attached the latest edition of our file. 

一个小例子,Maven项目是这里和战争的此处。如果您在Eclipse中运行项目或以

A minimal example maven project is here and the war is here. If you run the project in eclipse or with

mvn jetty:run

然后使用表单的http://本地主机:9095 / premier

您将得到一个无法连接服务器的异常。但是,如果你部署战争到Tomcat您将得到缺少启动边界例外。如果您编辑的applicationContext.xml和更换的 * 的*与有效值,它实际上将发送一封电子邮件。

You will get a "cannot contact server" exception. But if you deploy the war to tomcat you will get the missing start boundary exception. If you edit applicationContext.xml and replace the ** with valid values, it will actually send an email.

任何想法?

推荐答案

我想你的骆驼简化样的路线,它MVN码头运作良好:运行

I have tried your simplified camel route sample, it works well with mvn jetty:run.

在我的Tomcat 7.0.27,Java 6中,它的实际工作。邮件被正确发送。唯一的区别是我不使用

In my Tomcat 7.0.27, Java 6, it actually works. The mail was sent correctly. The only difference is I don't use the:

mvn install

而不是使用

mvn package

则目标/测试邮件0.0.1-SNAPSHOT.war复制到Tomcat的webapps文件夹,并启动tomcat(斌/ startup.sh或斌/的startup.bat)。

Then copy the target/test-mail-0.0.1-SNAPSHOT.war to the Tomcat webapps folder, and start tomcat (bin/startup.sh or bin/startup.bat).

希望这对你的作品也是如此。

Hope this works for you as well.

我的,你选择相同的Tomcat的版本我并遵循相同的步骤建议。

My suggestion that you pick the same Tomcat version as I had and follow the same step.

问题其他来源的你应该:

Other source of problem you should:


  1. 检查的是你是否有环境变量CATALINA_HOME或CATALINA_BASE懵懵懂懂给你设置为指向其他Tomcat安装。

  2. 此外,在环境变量,请检查您JRE_HOME或JAVA_HOME(使用JDK的时候),你的CLASSPATH变量的内容。您应该将类​​路径设置为$ JAVA_HOME / JRE / lib目录下:$ JAVA_HOME / JRE / lib / ext目录:.或%JAVA_HOME%/ JRE / lib目录;%JAVA_HOME%/ JRE / lib / ext目录;. (最后点很重要)

  3. 替换JAVA_HOME / lib目录与JRE_HOME如果您在JRE只。
  4. 运行
  5. 您运行的是什么版本的JVM。我使用的Oracle JDK 6.您使用的OpenJDK / J9或别的东西吗?

这篇关于缺少开始边界异常Tomcat中有附件文件发送邮件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆