Forum Home » Fuse Distributions » Fuse Mediation Router

Thread: Problem with jetty & javamail running camel under tomcat

 
This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 3 - Last Post: May 20, 2012 7:36 AM Last Post By: davsclaus
julianc

Posts: 24
Registered: 09/24/10
Problem with jetty & javamail running camel under tomcat
Posted: May 13, 2012 8:54 PM
 
  Click to reply to this thread Reply
I'm using Apache Camel to deliver a file as an email attachment. It works perfectly using the following maven goals:

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

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

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)

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.

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.

Versions:

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

Linux - the versions that come with ubuntu 10.04 LTS.

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>

This is what the log shows:

<pre>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.
</pre>

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

mvn jetty:run

and then use the form at http://localhost:9095/premier

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.

Any ideas?

davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Problem with jetty & javamail running camel under tomcat
Posted: May 14, 2012 1:33 AM   in response to: julianc in response to: julianc
Helpful
  Click to reply to this thread Reply
There is a java mail 1.4.5 release. Maybe that works?
julianc

Posts: 24
Registered: 09/24/10
Re: Problem with jetty & javamail running camel under tomcat
Posted: May 19, 2012 3:07 PM   in response to: davsclaus in response to: davsclaus
 
  Click to reply to this thread Reply
Thanks Claus, how would I change my pom to use that? Its picking the dependencies up from camel-mail with camel-version set to a fuse 2.8 version.

I've also shown that the most recent V7 tomcat fixes the problem, so its definately a class loader problem and jetty contains its own implementations of some of the java mail mime interfaces.
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Problem with jetty & javamail running camel under tomcat
Posted: May 20, 2012 7:36 AM   in response to: julianc in response to: julianc
 
  Click to reply to this thread Reply
You can add a dependency on the javax mail 1.4.5 in your pom.xml, then that should shadow the transitive dependency from camel-mail.