camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Elmore <>
Subject BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity
Date Mon, 13 Oct 2008 17:25:53 GMT

Here's a test case that illustrates the problem:

import junit.framework.Assert;
import junit.framework.TestCase;

import org.apache.camel.Exchange;
import org.apache.camel.component.bean.AmbiguousMethodCallException;
import org.apache.camel.component.bean.BeanInfo;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;

public class BeanInfoTest extends TestCase {
    protected DefaultCamelContext camelContext = new DefaultCamelContext();
    protected Exchange exchange = new DefaultExchange(camelContext);
	public void test() throws Exception {
		BeanInfo beanInfo = new BeanInfo(camelContext, Y.class);
		exchange.getIn().setBody(new Request());
		try {
			beanInfo.createInvocation(null, exchange);
		catch(AmbiguousMethodCallException e)
		{"This should not be ambiguous!");

class Request {
	int x;

class X {
	public int process(Request request) {
		return 0;

class Y extends X {
	public int process(Request request ) {
		return 1;

There should be no ambiguity here, since X.process() should be hidden by
Y.process(). This is causing me some issues, since I am using inheritance in
the beans invoked by my Camel routes. I can work around the issue using a
delegation pattern:

class Z {
	Y y = new Y();
	public int process(Request request ) {
		return y.process(request);

But obviously, I'd rather not have to do this.
View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message