camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsmahesh <aneesh_...@yahoo.co.in>
Subject sending email:getting error Error processing exchange. Exchange Message: Body is null.
Date Sat, 14 Sep 2013 06:35:56 GMT
Hi all,
I am geeting the error body is null when i m trying to send mail from camel.
My route is like,
<from uri="timer://foo?fixedRate=true&amp;period=60"/>
 <to uri="Email"/>
<bean id="Email" class="com.abc.mes.bw.cdc.EmailBodyClass"/>

I tried with following process methods,but i am getting the same error

@Override
	public void process(Exchange exchng) throws Exception {
		CamelContext context = null;
		// TODO Auto-generated method stub
	
		ProducerTemplate template = context.createProducerTemplate();
		Map map = new HashMap();
		map.put("To", "to=om_Integration_lowerenv@abc.com");
		map.put("From", "jstrachan@apache.org");
		map.put("Subject", "Camel rocks");

		String body = "Hello Claus.\nYes it does.\n\nRegards James.";
	
template.sendBodyAndHeaders("smtp://smtp.td.local?username=c_mahsom&amp;password=abcd&amp;to=om_Integration_lowerenv@abc.com",
body, map);
	
	}

@Override
	public void process(Exchange exchng) throws Exception {
		CamelContext context = null;
		// TODO Auto-generated method stub
		CamelContext context = null;
	    Endpoint endpoint =
context.getEndpoint("smtp://smtp.td.local?username=c_mahsom&amp;password=abcd&amp;to=om_Integration_lowerenv@abcd.com");
		Exchange exchange = endpoint.createExchange();
		Message in = exchange.getIn();
		in.setBody("Hello World");
		Producer producer = endpoint.createProducer();
		// start the producer
		producer.start();
		// and let it go (processes the exchange by sending the email)
		producer.process(exchange);
		
	}
	

Error processing exchange. Exchange[Message: [Body is null]]. Caused by:
[java.
lang.NullPointerException - null]
java.lang.NullPointerException
        at
com.outotec.mes.bw.energyconsumption.EmailBodyClass.process(EmailBody
Class.java:31)
        at
org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.
java:101)
        at
org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.j
ava:71)
        at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncP
rocessorBridge.process(AsyncProcessorConverterHelper.java:61)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:73)
        at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProc
essor.java:122)
        at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.j
ava:298)
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:1
17)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
er.java:73)
        at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
eAsyncProcessor.java:99)

kindly help me in setting the body of the mail.
thanks



--
View this message in context: http://camel.465427.n5.nabble.com/sending-email-getting-error-Error-processing-exchange-Exchange-Message-Body-is-null-tp5739344.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message