Question

I'm trying to import a package to a (.kar) bundle within the Karaf runtime that is being exported by another bundle. When I reference this package from within a bean in my .kar file I get an error. I have a bundle which is exporting a package namely "com.sample"

When I run packages:exports I can see the bundle that is being exported in the list, but when I reference it from my .kar file I get the following error:

The import com.sample cannot be resolved

at beans.testBean.<init>(testBean.java:5)
at bios.testdabean_0_1.testdabean$1.getCamelContextMap(testdabean.java:146)
at org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:386)
at bios.testdabean_0_1.testdabean$1.doStart(testdabean.java:161)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:148)
at bios.testdabean_0_1.testdabean.run(testdabean.java:194)
at bios.testdabean_0_1.testdabean.runJobInTOS(testdabean.java:290)
at org.talend.esb.job.controller.internal.RouteAdapter.run(RouteAdapter.java:78)[189:org.talen
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_51]

My manifest looks as follows

Manifest-Version: 1.0
Export-Package: ...
Bundle-ClassPath: ...
Bundle-Name: ...
Export-Service: ...
Require-Bundle: ...
Bundle-Vendor: ...
Bundle-Version: 0.1
Bundle-ManifestVersion: 2
Bundle-SymbolicName: .....
Import-Package: com.sample,org.osgi.service.blueprint,javax.xml.bind.annotation,
 ...

Any help would be greatly appreciated! Thanks

Was it helpful?

Solution

I found the solution to this if anyone is interested.

What I had to do was edit the route Manifest file to import the package that was being exported in the OSGi container. After that I had to reference the service through the Spring DM editor within the Studio.

I changed the namespace to look as follows.

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/bean/spring-  beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">

After that I could reference the service through the tag

<osgi:reference id="myUDPService" interface="com.myosgi.UDPService"/>

Once I had done this I just dropped a cBean, and referenced the bean through the Id "myUDPService", selected the method and was set to go!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top