2

I get method not found exception when I try to connect/call OSGI service using camel route and I am not sure what logic I am missing here.

//Exception

    Caused by: org.apache.camel.RuntimeCamelException: org.apache.camel.component.bean.MethodNotFoundException: Static method with name: getGreeting not found on class: com.test.api.Hello

//The below is the blueprint that exports osgi service

    <?xml version="1.0" encoding="UTF-8"?>
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
      <bean id="hello" class="com.test.HelloImpl"/>
      <service ref="hello" interface="com.test.api.Hello"/>
    </blueprint>

// Below is Java Interface and I did not include the java implementation code for interface here. but FYI, all method and class are declared as public

    package com.test.api;
    public interface Hello {
     public String getGreeting();
    }

//This below timer route is in Java DSL that is called by the route builder ref in the camel context and this camel context is defined inside blueprint

   from("timer:foo?repeatCount=1")
     .bean(com.test.api.Hello.class, "getGreeting")
     .log("The message contains: ${body}")


    

I got the same exception when I tried executing this route in the same bundle where I export interface service and also I tried executing this timer route in another separate bundle by referencing the exported OSGI interface.

I am testing/executing these bundles in Red Hat Fuse server.

Request for thumbs down audience: please specify the reason before you thumbs down so that helps me to ask question in better way in future.

Thanks!!

  • I expect that you tried making the method static? – Doug Grove Jun 24 '20 at 18:07
  • Thank you for the Response Doug, I am trying to call the OSGI interface service not the normal bean. I am not sure why should the method need to be declared static for the interface defined, if so the below code snippet also should throw the same exception but it does give good response. //Inside the routeBuilder from("timer:foo?repeatCount=1") .bean(HelloCamel.class,"doHandle") .log("The message contains: ${body}") //Bean package com.test.handler; public class HelloCamel{ public String doHandle(){ return "HelloWorld"; } – user11293713 Jun 24 '20 at 22:12

0 Answers0