The main ASF Bugzilla instance will be unavailable for 4 hours starting 19.00 UTC 2016-10-29 for an upgrade to 5.0.3
Bug 56797 - EL-API does not find overriden method
EL-API does not find overriden method
Product: Tomcat 7
Classification: Unclassified
Component: Jasper
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2014-07-31 15:55 UTC by S. Dabek
Modified: 2014-08-05 11:24 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description S. Dabek 2014-07-31 15:55:58 UTC
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.


    public CharSequence getCharSequence(CharSequence cs) {
        return cs;

    public String getCharSequence(CharSequence cs) {
        return cs.toString();

Test Case:

    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.
Comment 1 Christopher Schultz 2014-07-31 17:54:59 UTC
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 {

        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 error: method does not override or implement a method from a supertype
1 error

You may have to come up with a better test case.
Comment 2 S. Dabek 2014-07-31 19:27:16 UTC
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.
Comment 3 Christopher Schultz 2014-08-03 13:16:32 UTC
Aw, crap. I missed that, obviously. It's always easier to run a unit test when it comes in a self-contained example. ;)
Comment 4 Mark Thomas 2014-08-05 11:24:38 UTC
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.