-
1. Re: Servicemix-mail throwing "Content is not allowed in prolog"
ccustine Aug 31, 2009 2:07 PM (in response to dhillahbelo)What is the actual content of your message (is it text or html)? It would help to see the Content-Type of the mail message, the message body, and the complete stack trace if possible.
Chris
-
2. Re: Servicemix-mail throwing "Content is not allowed in prolog"
dhillahbelo Aug 31, 2009 3:03 PM (in response to ccustine)Thank you for your response.
Plain text. The content of the email is "Test Message"
I believe I have just figured out a workaround (or maybe this is the designed course of action?). If I use my own Marshaler and extend DefaultMailMarshaler to override convertMailToJBI similar to the following:
public class MyMailMarshaler extends DefaultMailMarshaler {
public void convertMailToJBI(MessageExchange exchange,
NormalizedMessage nmsg, MimeMessage mailMsg)
throws MessagingException {
super.convertMailToJBI(exchange, nmsg, mailMsg);
String mailContent = nmsg.getProperty("org.apache.servicemix.mail.text").toString();
mailContent = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><emailMessage>" + mailContent + "</emailMessage>";
try {
nmsg.setContent(new StringSource(mailContent));
} catch (javax.jbi.messaging.MessagingException e) {
e.printStackTrace();
}
}
}
(Also attached)
This seems to work. I am simply taking the plain text of the email, wrapping it with an XML tag, and setting the Content of the message to it. Without this, the DefaultMailMarshaler drops the plain text into the message content and I get the SAX parsing error because it is not XML. At least, that is what seems to be happening.
I am not sure if I would want DefaultMailMarshaler doing this, but it would probably beat it throwing an error. If all things reading the normalized message are looking for the content of the body of the email to be in the "org.apache.servicemix.mail.text" property then the content of the normalized message could be a simple <message/> or some other non-null and SAX parsable XML string. Perhaps DefaultMailMarshaler should drop in a dummy XML to the message content?
I hope this helps someone else. Thanks again for the response.
DHill
Edited by: dhillahbelo on Aug 31, 2009 6:56 PM
Edited by: dhillahbelo on Aug 31, 2009 7:03 PM
-
MyMailMarshaler.txt 629 bytes
-
-
3. Re: Servicemix-mail throwing "Content is not allowed in prolog"
ccustine Aug 31, 2009 5:10 PM (in response to dhillahbelo)You are correct, this looks like a bug in DefaultMailMarshaler. I don't think it is actually putting your message in the content, it appears to be putting a simple non-XML string ("no content"). I will open an issue on the Apache ServiceMix Jira and address this.
Your approach should work just fine, but to fix this I will more than likely put some dummy xml in there to keep the overhead low (in the case of a large text message) or at least make it an option in the marshaller config. In this case you will just be using the nmr message properties to get the message.
Chris
-
4. Re: Servicemix-mail throwing "Content is not allowed in prolog"
ccustine Sep 1, 2009 1:46 PM (in response to ccustine)This is now fixed at Apache and should be included in the next Fuse 4.1.0.x release and 4.2. New behavior adds <no-content /> as message content.