I probably need to see your complete configuration and a full DEBUG log.
I just wrote a test case and all worked as expected for me...
Code:
public class AdvisedMessageHandlerTests {
...
@Test
public void testEERHA() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("test-context.xml", this.getClass());
MessageChannel in = ctx.getBean("in", MessageChannel.class);
in.send(new GenericMessage<String>("foo"));
PollableChannel failures = ctx.getBean("failures", PollableChannel.class);
ErrorMessage failure = (ErrorMessage) failures.receive(1000);
assertNotNull(failure);
assertEquals("foo", ((MessagingException) failure.getPayload()).getFailedMessage().getPayload());
assertEquals("foo", ((MessageHandlingExpressionEvaluatingAdviceException) failure.getPayload()).getEvaluationResult());
}
public static class Foo {
public String foo(String bar) {
throw new RuntimeException("foo");
}
}
}
Code:
<int:channel id="in" />
<int:service-activator ref="foo" input-channel="in">
<int:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="trapException" value="true" />
<property name="failureChannel" ref="failures" />
<property name="onFailureExpression" value="payload" />
</bean>
</int:request-handler-advice-chain>
</int:service-activator>
<bean id="foo" class="org.springframework.integration.handler.advice.AdvisedMessageHandlerTests$Foo" />
<int:channel id="failures">
<int:queue />
</int:channel>
Code:
2013-01-18 18:37:57,347 [main] DEBUG: org.springframework.integration.channel.DirectChannel - preSend on channel 'in', message: [Payload=foo][Headers={timestamp=1358552277347, id=28bb2009-0492-4883-864f-795775fbab98}]
2013-01-18 18:37:57,347 [main] DEBUG: org.springframework.integration.handler.ServiceActivatingHandler - ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@6d581e80] received message: [Payload=foo][Headers={timestamp=1358552277347, id=28bb2009-0492-4883-864f-795775fbab98}]
2013-01-18 18:37:57,354 [main] DEBUG: org.springframework.integration.channel.QueueChannel - preSend on channel 'failures', message: [Payload=org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice$MessageHandlingExpressionEvaluatingAdviceException: Handler Failed][Headers={timestamp=1358552277354, id=c141dfd0-22b0-4bff-929b-1b70debfaeb6}]