I want to write the excpetion in a file :

*This is the route:*

<bean id="myExceptionHandler"
class="com.ngtrend.readmail2.MyExceptionHandler"/>

<route id="routeread">
<from uri="imap://URi?consumer.exceptionHandler=#myExceptionHandler"/>


this is what i set in *myExceptionHandler class:*

public class MyExceptionHandler implements ExceptionHandler {
        private ProducerTemplate template;
        public void *handleException*(String message,Throwable exception) {
                 handleException(exception.getMessage(), null, exception);  
        }

        @Override
         public void *handleException*(final String message, final Exchange
originalExchange, final Throwable exception) {
                 
                template.send("file://mail?fileName=mailtext3.txt", new 
Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setBody(message);
              
            }
        });
            }

 But it doesn't work got this error message:

WARN  Error handling exception. This exception will be ignored.
java.lang.NullPointerException

How can i fix it ?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Handle-Mail-exception-tp5772902.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to