Do you perhaps have the interface HelloBean in both bundles? If yes then you should extract it to a separate interface bundle.

Christian

Am 20.04.2012 18:23, schrieb Charles Moulliard:

e-03-06 | Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [java.lang.IllegalArgumentException - java.lang.ClassCastException@2bd040e8]
java.lang.IllegalArgumentException: java.lang.ClassCastException@2bd040e8
at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_31]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_31]
at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
at org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
at $Proxy83.sayHello(Unknown Source)
at com.mycompany.poc.client.HelloBean.sayHello(HelloBean.java:10)[216:route:1.0.0]

On Fri, Apr 20, 2012 at 6:17 PM, Christian Schneider <[email protected] <mailto:[email protected]>> wrote:

    If you reference the service with a filter then OSGi will inject
    the correct impl object. You will not even need to have a dynamic
    import as the impl is installed by the bundle1.

    So this should simply work. What exception do you get?

    Christian

    Am 20.04.2012 17:55, schrieb Charles Moulliard:
    Bundle 1 and Bundle 2 contain a different implementation of the
    interface which is exposed as OSGI service

    Bundle 1

    <bean id="service"
    class="com.mycompany.poc.service.impl.FeedbackTeamWS"/>

    <service ref="service"
    interface="com.mycompany.poc.service.Feedback">
    <service-properties>
    <entry key="version" value="1"/>
    </service-properties>
    </service>

    Bundle 2

    <bean id="service"
    class="com. mycompany.poc.service.impl.FeedbackTeamDB"/>

    <service ref="service"
    interface="com.mycompany.poc.service.Feedback">
    <service-properties>
    <entry key="version" value="2"/>
    </service-properties>
    </service>

    So the bundle C do an OSGI lookup to retrieve using as key the
    interface name "com.mycompany.poc.service.Feedback", the class
    implemented in bundle 1 or bundle 2.

    What would be great is that the bundle C when the following bean
    is instantiated loads the class from the bundle 1 as the filter
    of the reference to be found corresponds to it

    <property name="feedbackService">
    <reference interface="com.mycompany.poc.service.Feedback"
    filter="(version=1)"/>
    </property>

    Intrinsically we know that the class implementing this interface
    belongs to bundle 1 as filter = 1 = OSGI service exposed by
    bundle 1 = class = com.mycompany.poc.service.impl.FeedbackTeamWS


-- Christian Schneider
    http://www.liquid-reality.de

    Open Source Architect
Talend Application Integration Divisionhttp://www.talend.com



--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com

Reply via email to