I tried that and got a nested NPE.

Jan


2013-11-25 08:05:29,427 [main           ] ERROR DefaultErrorHandler
- Failed delivery for (MessageId: ID-Jan-mySN-54051-1385363128177-0-1 on
ExchangeId: ID-Jan-mySN-54051-1385363128177-0-2). Exhausted after delivery
attempt: 1 caught: org.apache.camel.TypeConversionException: Error during
type conversion from type: org.apache.camel.component.exec.ExecResult to the
required type: byte[] with value
org.apache.camel.component.exec.ExecResult@71e2cfdc due
java.lang.NullPointerException

Message History
----------------------------------------------------------------------------
-----------------------------------------------------------
RouteId              ProcessorId          Processor
Elapsed (ms)
[route2            ] [route2            ] [direct://exec
] [       255]
[route2            ] [to2               ] [exec:java?args=-version
] [       240]
[route2            ] [to3               ] [stream:out
] [         5]

Exchange
----------------------------------------------------------------------------
-----------------------------------------------------------
Exchange[
        Id                  ID-Jan-mySN-54051-1385363128177-0-2
        ExchangePattern     InOnly
        Headers
{breadcrumbId=ID-Jan-mySN-54051-1385363128177-0-1, CamelExecExitValue=0,
CamelExecStderr=java.io.ByteArrayInputStream@53d5f8be,
CamelRedelivered=false, CamelRedeliveryCounter=0}
        BodyType            org.apache.camel.component.exec.ExecResult
        Body                
]

Stacktrace
----------------------------------------------------------------------------
-----------------------------------------------------------
org.apache.camel.TypeConversionException: Error during type conversion from
type: org.apache.camel.component.exec.ExecResult to the required type:
byte[] with value org.apache.camel.component.exec.ExecResult@71e2cfdc due
java.lang.NullPointerException
        at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseType
ConverterRegistry.java:130)[camel-core-2.12.0.jar:2.12.0]
        at
org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:72)[camel-c
ore-2.12.0.jar:2.12.0]
        at
org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47)[camel-c
ore-2.12.0.jar:2.12.0]
        at
org.apache.camel.component.stream.StreamProducer.writeToStream(StreamProduce
r.java:128)[camel-stream-2.12.0.jar:2.12.0]
        at
org.apache.camel.component.stream.StreamProducer.process(StreamProducer.java
:79)[camel-stream-2.12.0.jar:2.12.0]
  [...]

Output of Eclipse JUnitRunner
----------------------------------------------------------------------------
-----------------------------------------------------------
org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: ]
        at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.
java:1360)
        at
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:6
19)
  [...]
Caused by: org.apache.camel.TypeConversionException: Error during type
conversion from type: org.apache.camel.component.exec.ExecResult to the
required type: byte[] with value
org.apache.camel.component.exec.ExecResult@71e2cfdc due
java.lang.NullPointerException
        at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseType
ConverterRegistry.java:130)
        at
org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:72)
        at
org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47)
        at
org.apache.camel.component.stream.StreamProducer.writeToStream(StreamProduce
r.java:128)
  [...]
Caused by: org.apache.camel.RuntimeCamelException:
java.lang.NullPointerException
        at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.ja
va:1344)
        at
org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:986)
        at
org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMe
thodTypeConverter.java:59)
        at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTy
peConverterRegistry.java:275)
        at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseType
ConverterRegistry.java:113)
        ... 51 more
Caused by: java.lang.NullPointerException
        at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1025)
        at org.apache.commons.io.IOUtils.copy(IOUtils.java:999)
        at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:218)
        at
org.apache.camel.component.exec.ExecResultConverter.convertToByteArray(ExecR
esultConverter.java:56)
  [...]


> -----Ursprüngliche Nachricht-----
> Von: Philippe de Rochambeau [mailto:[email protected]]
> Gesendet: Sonntag, 24. November 2013 22:28
> An: [email protected]
> Betreff: Problem with exec
> 
> 
> 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");

Reply via email to