In your processor, since you are requesting the object contained in the message 
body as a particular type, it is possible for the value to be null if that is 
not the type that is actually on the body. Would you be able to verify the 
object type after the unmarshall.? You can do this in your processor by getting 
the Object on the message without a type (message.getIn().getBody() and 
checking the type. 

- Andy


-- 
Andrew Block

On October 10, 2015 at 3:46:52 PM, Bhuvan Gupta ([email protected]) wrote:

Hello,  

I setup the camel routes shown below:  
In stage folder i can see message getting marshal properly into a json.  
but while un-marshaling on this line body.setA("modified A");  
i get a null pointer exception basically body is null.. *Why* ?  

StackOverflow question link:  
http://stackoverflow.com/questions/33058563/adding-a-processor-after-unmarshaling-in-apache-camel
  

from("direct:stage").marshal().json(JsonLibrary.Gson).to("file://stage");  

from("file://stage").unmarshal().json(JsonLibrary.Gson).process(new  
Processor() {  
@Override  
public void process(Exchange exchange) throws Exception {  
MyTest body = exchange.getIn().getBody(MyTest.class);  
body.setA("modified A");  
}}).to("direct:b");  

Reply via email to