Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11240

Simple Language: MethodNotFoundException when calling interface method implemented by super class

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.19.0
    • Fix Version/s: 2.19.1, 2.20.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown
    • Regression:
      Regression

      Description

      After updating from 2.18.3 to 2.19.0 this test fails:

      package test;
      
      import org.apache.camel.EndpointInject;
      import org.apache.camel.Produce;
      import org.apache.camel.ProducerTemplate;
      import org.apache.camel.builder.ExchangeBuilder;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.component.mock.MockEndpoint;
      import org.apache.camel.test.junit4.CamelTestSupport;
      import org.junit.Test;
      
      public class MethodNotFoundExceptionTestSimplified extends CamelTestSupport {
      
          public static interface InterfaceEmpty {
              boolean isEmpty();
          }
      
          public static class SuperClazz {
              public boolean isEmpty() {
                  return true;
              }
          }
      
          public static class Clazz extends SuperClazz implements InterfaceEmpty {
          }
      
          public static class MethodNotFoundExceptionRoute extends RouteBuilder {
      
              @Override
              public void configure() throws Exception {
                  from("seda:in").choice().when(simple("${headers.bean.isEmpty()}")).to("mock:out");
              }
          }
      
          @Produce(uri = "seda:in")
          private ProducerTemplate in;
      
          @EndpointInject(uri = "mock:out")
          private MockEndpoint out;
      
          @Override
          protected RouteBuilder createRouteBuilder() {
              return new MethodNotFoundExceptionRoute();
          }
      
          @Test
          public void methodNotFoundExceptionException() throws Exception {
              out.expectedMessageCount(1);
      
              ExchangeBuilder exchangeBuilder = new ExchangeBuilder(context).withHeader("bean", new Clazz());
              in.send(exchangeBuilder.build());
      
              out.assertIsSatisfied();
          }
      }

      with:

      22:35:38.069 [Camel (camel-1) thread #0 - seda://in] ERROR org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-Redhawk-THINK-50332-1494275736472-0-3 on ExchangeId: ID-Redhawk-THINK-50332-1494275736472-0-4). Exhausted after delivery attempt: 1 caught: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: isEmpty() on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: isEmpty() (with no parameters) not found on bean: test.MethodNotFoundExceptionTestSimplified$Clazz@61a86839 of type: test.MethodNotFoundExceptionTestSimplified$Clazz. Exchange[]
      
      Message History
      ---------------------------------------------------------------------------------------------------------------------------------------
      RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
      [route1            ] [route1            ] [seda://in                                                                     ] [      1025]
      [route1            ] [choice1           ] [when[simple{Simple: ${headers.bean.isEmpty()}}]choice[]                       ] [        33]
      
      Stacktrace
      ---------------------------------------------------------------------------------------------------------------------------------------
      org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: isEmpty() on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: isEmpty() (with no parameters) not found on bean: test.MethodNotFoundExceptionTestSimplified$Clazz@61a86839 of type: test.MethodNotFoundExceptionTestSimplified$Clazz. Exchange[]
      	at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:327)
      	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:115)
      	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:139)
      	at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:126)
      	at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:118)
      	at org.apache.camel.builder.ExpressionBuilder$KeyedOgnlExpressionAdapter.evaluate(ExpressionBuilder.java:2490)
      	at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
      	at org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32)
      	at org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:35)
      	at org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:85)
      	at org.apache.camel.processor.FilterProcessor.matches(FilterProcessor.java:65)
      	at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:93)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
      	at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:298)
      	at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:207)
      	at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:154)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method with name: isEmpty() (with no parameters) not found on bean: test.MethodNotFoundExceptionTestSimplified$Clazz@61a86839 of type: test.MethodNotFoundExceptionTestSimplified$Clazz. Exchange[]
      	at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:273)
      	at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:189)
      	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:160)
      	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
      	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:69)
      	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:212)
      	at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:323)
      	... 20 common frames omitted
      22:35:38.070 [Camel (camel-1) thread #0 - seda://in] WARN org.apache.camel.component.seda.SedaConsumer - Error processing exchange. Exchange[]. Caused by: [org.apache.camel.language.bean.RuntimeBeanExpressionException - Failed to invoke method: isEmpty() on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: isEmpty() (with no parameters) not found on bean: test.MethodNotFoundExceptionTestSimplified$Clazz@61a86839 of type: test.MethodNotFoundExceptionTestSimplified$Clazz. Exchange[]]
      org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: isEmpty() on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: isEmpty() (with no parameters) not found on bean: test.MethodNotFoundExceptionTestSimplified$Clazz@61a86839 of type: test.MethodNotFoundExceptionTestSimplified$Clazz. Exchange[]
      	at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:327)
      	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:115)
      	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:139)
      	at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:126)
      	at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:118)
      	at org.apache.camel.builder.ExpressionBuilder$KeyedOgnlExpressionAdapter.evaluate(ExpressionBuilder.java:2490)
      	at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
      	at org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32)
      	at org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:35)
      	at org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:85)
      	at org.apache.camel.processor.FilterProcessor.matches(FilterProcessor.java:65)
      	at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:93)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
      	at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:298)
      	at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:207)
      	at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:154)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method with name: isEmpty() (with no parameters) not found on bean: test.MethodNotFoundExceptionTestSimplified$Clazz@61a86839 of type: test.MethodNotFoundExceptionTestSimplified$Clazz. Exchange[]
      	at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:273)
      	at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:189)
      	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:160)
      	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
      	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:69)
      	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:212)
      	at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:323)
      	... 20 common frames omitted
      

      This is a simplified example, a real example are java.util.LinkedHashSet#isEmpty and isEmpty methods of guava collection classes.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                pascalschumacher Pascal Schumacher
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: