Util.findWrapper(..) returns with a MethodNotFoundException (util.method.ambiguous) under the following conditions: - A method is overriden and the return type in the overriden method is inherited from the original method's return type - The method is called with a parameter whose type is inherited from the declared type (assignable) Apparently, this leads to a situation with multiple matches. If only one of those conditions is true, the error does not occur. Example: -------- TesterBeanA.java: public CharSequence getCharSequence(CharSequence cs) { return cs; } TesterBeanAA.java @Override public String getCharSequence(CharSequence cs) { return cs.toString(); } Test Case: ---------- TestMethodExpressionImpl.java: @Test public void testInvokeOverridenParamAndReturnType() { MethodExpression me = factory.createMethodExpression(context, "${beanAA.getCharSequence('test')}", null , new Class<?>[] { TesterBeanB.class }); assertEquals("test", me.invoke(context, null)); } Note 1: The error also occurs if getCharSequence(..) in TesterBeanA is abstract. I suggest adding a check for isAbstract() upon reading method modifiers and drop abstract method right away. Note 2: This worked in Tomcat 7.0.40.
That's because the method is ambiguous. Even Java can't figure it out. Something is wrong with your sample code: it won't compile. public class AmbiguousTest { public static class TesterBeanA { public CharSequence getCharSequence(CharSequence cs) { return cs; } } public static class TesterBeanAA { @Override public String getCharSequence(CharSequence cs) { return cs.toString(); } } public static void main(String[] args) { new TesterBeanAA().getCharSequence("test"); } } The code above will not compile under Java 8: $ javac AmbiguousTest.java AmbiguousTest.java:11: error: method does not override or implement a method from a supertype @Override ^ 1 error You may have to come up with a better test case.
The test-code is fine. Of course, it won't compile if you don't extend TesterBeanAA from TesterBeanA. Just add the code to the test-classes of the same name in the tomcat7 trunk. And of course an overriden method can't be ambiguous. That's the essence of polymorphism.
Aw, crap. I missed that, obviously. It's always easier to run a unit test when it comes in a self-contained example. ;)
Thanks for the report. This has been fixed in 8.0.x for 8.0.11 onwards and in 7.0.x for 7.0.56 onwards.