0

I am trying to install a latest version of my apache camel application using feature:install on Karaf this new version has a dependency of org.apache.commons.configuration ver 1.9 but getting the below error

error:

Error executing command: Could not start bundle mvn: in feature(s)<package> : Unresolved constraint in bundle <bundle> [414]: Unable to resolve 414.0: missing requirement [414.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.commons.configuration)(version>=1.9.0)(!(version>=2.0.0)))

I had included it in the pom.xml

<dependency>
        <groupId>commons-configuration</groupId>
        <artifactId>commons-configuration</artifactId>
        <version>1.9</version>
    </dependency>

also have tried several ways suggested in sof but none is working

have also put the for org.apache.commons.configuration under the plugins

        <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Import-Package>
                        org.apache.cxf.service.model,
                        org.apache.cxf.message,
                        org.apache.commons.configuration,
                        *
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>

But still not able to resolve. Could anyone please help resolve this?

thanks

user3593025
  • 21
  • 2
  • 10

2 Answers2

1

You need to ensure that the jar is installed in Karaf. In order to do this you need to wrap the jar as a bundle:

osgi:install wrap:mvn:commons-configuration/commons-configuration/1.9

After you've done this make sure to remove the addition you made to Import-Package as it's not needed.

If you want the dependency to be installed along with your application's feature just add the following element to your feature:

<bundle>wrap:mvn:commons-configuration/commons-configuration/1.9</bundle>
Erik Karlstrand
  • 1,479
  • 9
  • 22
0

Do you really want to import it from another deployed bundle or should it be a simple embedded dependency?

Since you list it under Import-Package, you expect the first. For that to work you need to have another bundle deployed in the container that exports org.apache.commons.configuration.

If you want to embedded it as simple dependency in the same bundle, you have to exclude it from Import-Package with ! as prefix and probably use Embed-Dependency instruction like the example in this answer: https://stackoverflow.com/a/30532447/8035582

burki
  • 6,741
  • 1
  • 15
  • 31
  • Hi @burki, thanks for your response. Initially I just had added for the configuration. even then it was the same error. then as per few of stackoverflow threads , I included it in the to include this.. but even it didnt worked. So if I prefix ! or remove the and use , will it work? – user3593025 Jan 12 '18 at 10:55
  • just creates a build-time dependency in Maven, it has no effect on the runtime. You need to make sure the bundle is actually included in your runtime application. – Neil Bartlett Jan 12 '18 at 11:10
  • 1
    Using Embed-Dependency everywhere is not a general solution to unresolved imports, since it leads to every bundle containing copies of the same API. This leads to very large bundles that cannot communicate with each other. – Neil Bartlett Jan 12 '18 at 11:12
  • The default value of `Import-Package` is `*`. That means: import all packages (which are required by the bundle's contained packages) from other bundles in the same osgi-container. That explains why you got the same error only by adding the dependency. So if it is not provided by another bundle in the container, you have to exclude it from `Import-Package` and embed it in your bundle. You can do that by using `Embed-Dependency`. You can, for example, embed all compile time dependencies with `*;scope=compile`. – burki Jan 12 '18 at 11:20
  • Hi @burki, I tried the suggestion removing the org.apache.commons.configuration from the and restoring back to original with org.apache.cxf.service.model, org.apache.cxf.message, * . Now the error is not showing on org.apache.commons.configuration but this one is got this time: Unable to resolve 760.0: missing requirement [760.0] osgi.wiring.package; (osgi.wiring.package=com.twitter.util – user3593025 Jan 12 '18 at 11:39
  • @user3593025 That message means that your bundle depends on the package `com.twitter.util`. You will need a bundle that exports that package to be included in the runtime. Or you could just embed that one as well but hopefully you see where this is going and that embedding everything that you depend on is not a real solution! – Neil Bartlett Jan 12 '18 at 11:42
  • have also included the *;scope=compile – user3593025 Jan 12 '18 at 11:47
  • @NeilBartlett, can you then please suggest how to achieve for runtime? thanks – user3593025 Jan 12 '18 at 11:48
  • As @NeilBartlett already pointed out, you have to decide if you want to build an "isolated fat-bundle" that embeds all dependencies or if you want to build multiple small bundles, some of them export "shared" dependencies for others to import (one of the main reasons to use an osgi-container). Either way, you have to study and play with the instructions of the [felix-maven-bundle](http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html) – burki Jan 12 '18 at 12:00
  • @user3593025 I did suggest how to make this work. Simply include the bundle that exports the package that you need in the runtime. This is the normal task of constructing an application: if your code has dependencies, you have to make sure those dependencies are available when you run. – Neil Bartlett Jan 12 '18 at 12:15