You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "paul-mcculloch (via GitHub)" <gi...@apache.org> on 2025/01/10 09:50:49 UTC

[I] osgi - Bean method invocations where the bean is a proxy for an Interface & the method has no arguments fail with AmbiguousMethodCallException [camel-karaf]

paul-mcculloch opened a new issue, #565:
URL: https://github.com/apache/camel-karaf/issues/565

   [Originally logged as https://issues.apache.org/jira/browse/CAMEL-20436 but closed with instructions to log here]
   
   Using OSGi Blueprint a <reference> element can be used to inject an OSGi service into Camel. Methods on the injected service can be called via "bean:someref?method=foo"
   
   The service is injected as a proxy to the actual OSGi service,
   
   When BeanInfo attempts to resolve the method it sees two methods named 'foo' : The abstract method of the interface,  and the concrete method of the proxy.
   
   In camel 3.16 & earlier BeanInfo.findMostSpecificOverride() would determine that one method overrode the other, and would return the proxy's method.
   
   From 3.17 onwards a changes was made to look at the method's declaring class' isSynthetic() value, and to not consider a synthetic class' method as overriding the interface. The blueprint proxy is synthetic so is affected. 
   
    
   
   The changes was made for https://issues.apache.org/jira/browse/CAMEL-17844 (https://github.com/apache/camel/pull/7261/commits/5d956d2e4914a5c4fe73e5cae2f2ea7d2429f8e3)
   
    
   
   This can be worked around by changing the method to take at least one argument. This triggers a different path through the code  - attempting to match the exchange body to the parameter. In this path the isSynthetic() flag isn't considered.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] osgi - Bean method invocations where the bean is a proxy for an Interface & the method has no arguments fail with AmbiguousMethodCallException [camel-karaf]

Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre closed issue #565: osgi - Bean method invocations where the bean is a proxy for an Interface & the method has no arguments fail with AmbiguousMethodCallException
URL: https://github.com/apache/camel-karaf/issues/565


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] osgi - Bean method invocations where the bean is a proxy for an Interface & the method has no arguments fail with AmbiguousMethodCallException [camel-karaf]

Posted by "tim08 (via GitHub)" <gi...@apache.org>.
tim08 commented on issue #565:
URL: https://github.com/apache/camel-karaf/issues/565#issuecomment-3243884801

   @essobedo to reproduce the problem:
   bundle 1
   
   ```
   package my.test;
   
   public interface MyService {
       String myMethod();
   }
   ```
   ```
   package my.test;
   
   public class MyServiceImpl implements MyService{
       @Override
       public String myMethod() {
           return "test1";
       }
   }
   ```
   in blueprint
   ```
   <bean class="my.test.MyServiceImpl" id="myServiceImpl"/>
   <service ref="myServiceImpl" interface="my.test.MyService"/>
   ```
   
   bundle 2
   in blueprint
   
   ```
       <reference id="myService"
                  interface="my.test.MyService"
                  timeout="30000" availability="mandatory"/>
       <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="mytest">
           <route>
               <from uri="timer://letsgo?repeatCount=1"/>
               <to uri="bean:myService?method=myMethod" />
               <to uri="log:test" />
           </route>
       </camelContext>
   ```
   @paul-mcculloch I was able to partially solve the problem using
   `<to uri="bean:my.test.MyService?method=myMethod" />`
   or if you need to set some header
   ```
               <setHeader name="myCustomHeader">
                   <method method="myMethod()" beanType="my.test.MyService"/>
               </setHeader>
   ```
   but sometimes I get a class missing error, I think it depends on the order of loading bundles (maybe as a fix use different start-level), or using lazyStartProducer https://camel.apache.org/components/4.10.x/bean-component.html


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org