How do you know you've got this issue? You execute a test application from your IDE to see if an e-mail will be sent, to your surprise everything works perfect. But when you deploy the application to either Tomcat, Jboss or Glassfish server, the message is sent with header and footer details as part of the mesage body. The massage body typically resembles below;
------=_Part_0_25002283.1275298567928 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello Mark Doe, This message is found as a culprit. Regards, Joe Blahh ------=_Part_0_25002283.1275298567928
Also if you are attaching documents to this email message, the attachment is sent with base64 encode as part of the message body. Typical attachment message will look like this;
------=_Part_0_25002283.1275298567928 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello Mark Doe, This message is found as a culprit. Regards, Joe Blahh ------=_Part_0_25002283.1275298567928 Content-Type: application/pdf; name="file.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="file.pdf" Content-Description: Some attachment JVBERi0xLjQNJeLjz9MNCjYzIDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDMxMzE4Mi9PIDY1L0Ug Mjg2NjY5L04gMS9UIDMxMTgwMi9IIFsgMjgzNiAzNzZdPj4NZW5kb2JqDSAgICAgICAgICAgICAg DQp4cmVmDQo2MyAxMjcNCjAwMDAwMDAwMTYgMDAwMDAgbg0KMDAwMDAwMzM4MCAwMDAwMCBuDQow MDAwMDAzNTIzIDAwMDAwIG4NCjAwMDAwMDQzMDcgMDAwMDAgbg0KMDAwMDAwNTEwOSAwMDAwMCBu DQowMDAwMDA2Mjc5IDAwMDAwIG4NCjAwMDAwMDY0MTAgMDAwMDAgbg0KMDAwMDAwNjU0NiAwMDAw MCBuDQowMDAwMDA3OTY3IDAwMDAwIG4NCjAwMDAwMDkwMjMgMDAwMDAgbg0KMDAwMDAwOTk0OSAw MDAwMCBuDQowMDAwMDExMDAwIDAwMDAwIG4NCjAwMDAwMTIwNTkgMDAwMDAgbg0KMDAwMDAxMjky MCAwMDAwMCBuDQowMDAwMDEyOTU0IDAwMDAwIG4NCjAwMDAwMTI5ODIgMDAwMDAgbg0KMDAwMDAx ....... CnN0YXJ0eHJlZg0KMTE2DQolJUVPRg0K ------=_Part_0_25002283.1275298567928--
If you've run into this culprit, don't worry too much. Go grab a cuppa coffee, and while you're relaxed look through your Maven dependency to see if you have geronimo-javamail_1.4_spec-1.2 along with geronimo-activation_1.1_spec, because your project build will rely on these. You can do this by issuing below Maven2 commands;
mvn dependency:treeOptionally, the output parameter can be specified to divert the output to a file:
mvn dependency:tree -Doutput=/path/to/file
Causes:
The described issue is caused by transitive dependencies of Apache CXF 2 or Axiom.
SOLUTION:
To resolve this issue, exclude geronimo-javamail_1.4_spec from the build, and just rely on javax's mail-1.4.x.jar.
org.apache.cxf cxf-rt-frontend-jaxws 2.2.6 org.apache.geronimo.specs geronimo-javamail_1.4_spec org.apache.geronimo.specs geronimo-activation_1.1_spec
org.apache.ws.commons.axiom axiom-api 1.2.8 org.apache.geronimo.specs geronimo-activation_1.1_spec org.apache.geronimo.specs geronimo-javamail_1.4_spec
Thanks. This solved our problems, though I imagine I should eventually look into the root cause for this behavior. Some configuration file that is part of geronimo?
ReplyDeleteSorry for the long break in response, the root cause of the issue is what is discussed above. geronimo has its own dependency, and therefore playing with it configuration file will cause more issues for you.
ReplyDeleteOne thing I will point out though, is if you've got redundancy of shared dependancies floating around your project - try to manage them effectively by exclusion.
You obviously need to be carefull not to replace crucial versions due to forward and backward compactibility issues.