Hello everybody!

In a highly integration based project we would like to use the camel exec://
component. My first tests however let me ask why some executables that must
be in the system path by default are not found with exec://. Please see the
following example:

public class TestCamelExecSpike extends CamelTestSupport {

        private static final Logger logger =
LoggerFactory.getLogger(TestCamelExecSpike.class);
        private static final String echoExecutable = "echo";
        private static final String echoParam = "Hello world";

        @Override
        protected RouteBuilder createRouteBuilder() throws Exception {
                return new RouteBuilder() {
                        @Override
                        public void configure() throws Exception {
                                from("direct:startExec").to("exec:" + 
echoExecutable + "?args=" +
echoParam).to(
                                                "mock:result");
                        }
                };
        }

        @Test
        public void testCamelExec() throws Exception {

                MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
                mockEndpoint.expectedMessageCount(1);

                template.sendBody("direct:startExec", null);

                mockEndpoint.assertIsSatisfied();
                List<Exchange> exchanges = mockEndpoint.getExchanges();
                String stdout = exchanges.get(0).getIn().getBody(String.class);
                logger.info(stdout);
                assertEquals("Hello world", stdout);
        }
}

When I execute the test I encounter the following error:

org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: [Body is null]]
        at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1296)
        at
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:618)
        at
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:442)

Caused by: org.apache.camel.component.exec.ExecException: *Unable to execute
command ExecCommand [args=[Hello, world], executable=echo,
timeout=9223372036854775807, outFile=null, workingDir=null,
useStderrOnEmptyStdout=false]*
        at
org.apache.camel.component.exec.impl.DefaultExecCommandExecutor.execute(DefaultExecCommandExecutor.java:81)
        at
org.apache.camel.component.exec.ExecProducer.process(ExecProducer.java:46)
        at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

Actually the command /echo/ should be found but it wasn't. Can someone
please explain me how the system path can be set properly to avoid setting
the whole path for the executables?

Thanks
Hilde

--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-exec-System-Path-is-empty-tp5715145.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to