As the output has not been converted, you get a NPE.

I suggest that you have a look to this example as they show you how to do
the conversion

https://github.com/apache/camel/blob/master/components/camel-exec/src/test/java/org/apache/camel/component/exec/ExecJavaProcessTest.java


On Sun, Nov 24, 2013 at 10:28 PM, Philippe de Rochambeau <[email protected]>wrote:

>
> Hello,
>
> I have adapted the « exec » example shown on the
> http://camel.apache.org/exec.html page, as follows.
>
> Unfortunately, nothing appears on the console.
>
> Why is that?
>
> Many thanks.
>
> Philippe
>
>
> from("direct:exec")
> .to("exec:/usr/bin/java?args=-server -version")
> .process(new Processor() {
> public void process(Exchange exchange) throws Exception {
> // By default, the body is ExecResult instance
> // assertIsInstanceOf(ExecResult.class, exchange.getIn().getBody());
> // Use the Camel Exec String type converter to convert the ExecResult to
> String
> // In this case, the stdout is considered as output
>
> Object obj = exchange.getIn().getBody();
> Object obj1 = exchange.getIn().getHeader(ExecBinding.EXEC_EXIT_VALUE);
> System.out.println("obj = " + obj);
> System.out.println("obj1 = " + obj1);
> }
> })
> .to("stream:out");




-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Reply via email to