One Star

Talend ESB runtime bundle resolution problem

Hi,
I created a route which uses camel-csv as a dependency (configured in the route using cConfig component).
It works fine in the studio, but when I deploy it in the Runtime, I get an error message saying that it can not resolve camel-csv bundle.
Camel-csv feature is installed and started, camel-csv bundle is active, but it is not found when I try to install the kar file containing my route.
I have noticed that the bundle name in the error message is : camel_csv (with an _ instead of -). Is this normal or could it be the cause of the problem ?
Error message : missing requirement osgi.wiring.bundle=camel_csv; filter:="(osgi.wiring.bundle=camel_csv)"
Thanks.
: I am using Talend ESB Runtime 6.1.1
4 REPLIES
Employee

Re: Talend ESB runtime bundle resolution problem

The reason you are getting the error message is that when you deploy to the runtime you are using Karaf and hence you need to configure your OSGI dependencies.  OSGI allows you to manage those dependencies at the package level.  In contrast, when you run the route from Studio as a developer it is just running in a regular jar and the Studio is adding the camel-csv to the classpath. 
You have two options here.  Notice that in 6.1.1 there is a new dependencies tab underneath the design canvas right next to Designer and Source views.  A screenshot is shown below.

Any jars you add via cConfig will show up here under Bundle Classpath.  You have two choices.  If you check the box next to camel-csv in the BundleClasspath box you will be adding the camel-csv as an embedded jar on the bundle classpath.  This will work, but it means if you have another route with camel-csv you are actually adding multiple jars to your Karaf environment, one per route which uses the camel-csv with bundle classpath.  Personally, I don't like this approach.
The other approach is to use the Import Packages pane to of specify the additional packages that your code references from the camel-csv jar.  Along with installing the camel-csv feature (as you did) this will cause the camel-csv package dependencies to be included in your route's bundle manifest.  Karaf will then use the jar from the camel-csv feature that you installed.  This requires a little bit more work (manually adding the camel-csv packages and also remembering to install the camel-csv feature), but it is more in line with how OSGI is supposed to be used IMO.
One Star

Re: Talend ESB runtime bundle resolution problem

Thank you for your answer.
The second option you mentionned is what I am trying to do.
However, 
- I don't understand the "package" thing : how can I know which packages I have to manually add in the "import packages" list
- In the "dependencies" view, there is also a "Require Bundles" list. There, in my case, there is a bundle called "camel_csv" (notice the underscore), which is strange because the actual bundle name is "camel-csv" AFAIK. When I try to edit and modify the name to "camel-csv", I get an error message saying that this is not a valid Java identifier. I think this is the cause of my problem : I do not understand why the Studio does not allow bundle names with '-' ???
Employee

Re: Talend ESB runtime bundle resolution problem

You can get the list of package dependencies for a bundle from the karaf commandline with the bundle:headers command.  For example, for the camel-csv bundle on my machine, the bundle id is 462.  you can see below that the only package exported is  org.apache.camel.dataformat.csv .
karaf@trun()> bundle:headers 462
camel-csv (462)
---------------
Bnd-LastModified = 1445637469825
Build-Jdk = 1.7.0_75
Built-By = vagrant
Created-By = Apache Maven Bundle Plugin
Implementation-Title = Apache Camel
Implementation-Version = 2.15.4
Manifest-Version = 1.0
Tool = Bnd-1.50.0
Karaf-Info = Camel;camel-csv=2.15.4
Bundle-Description = Camel CSV data format support
Bundle-DocURL = http://www.apache.org/
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2
Bundle-Name = camel-csv
Bundle-SymbolicName = org.apache.camel.camel-csv
Bundle-Vendor = The Apache Software Foundation
Bundle-Version = 2.15.4
Export-Service =
        org.apache.camel.spi.DataFormatResolver;dataformat=csv
Export-Package =
        org.apache.camel.dataformat.csv;
                uses:="org.apache.camel,
                        org.apache.commons.csv,
                        org.apache.camel.spi,
                        org.apache.camel.util,
                        org.apache.camel.support";
                version=2.15.4
Import-Package =
        org.apache.camel;version="[2.15,2.16)",
        org.apache.camel.spi;version="[2.15,2.16)",
        org.apache.camel.support;version="[2.15,2.16)",
        org.apache.camel.util;version="[2.15,2.16)",
        org.apache.commons.csv;version="[1.1,2)",
        org.osgi.framework.wiring;version="[1.0,2)"

karaf@trun()>
One Star

Re: Talend ESB runtime bundle resolution problem

Ok thanks for this explanation.
I solved my problem by :
- removing everything in the "Required bundles" view
- adding nothing more in the "Import packages" view (so the package org.apache.camel.dataformat.csv is *not* in the import packages)
- unchecking all the jars in the "Bundle classpath" view
- rebuilding the route
My route is working fine in the runtime, even if I don't understand how the dependencies are managed : as it is now, nothing in my kar file (feature.xml or MANISFEST.MF in the route jar) references camel-csv. So I guess it just works because I installed camel-csv feature in the Runtime, and my route somehow finds what it needs in the classpath ...