Could not start bundle Unresolved constraint in bundle osgi.wiring.package=org.apache.commons.configuration version>=1.9.0 ! version>=2.0.0 - maven

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

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>

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

Related

Missing dependency while upgrading AEM 6.5.1 to 6.5.10

I am upgrading AEM 6.5.1 (Service pack 1) to AEM 6.5.10 (Service pack 10). For this I installed SP10 in AEM as well updated the uber-jar version to 6.5.10 in my source code POM.xml file.
I see that in the OSGI console, my bundle is in Installed and not Active state. This is because certain dependencies (which before the update were not present) are missing. I have been able to get those dependencies, except one.
com.microsoft.schemas.office.powerpoint -- Cannot be resolved
I am unable to find any JARs online that fixes this issue. I tried Apache POI but no success. Does anyone know what this dependency is and where I can get it?
Thanks!
If you are not using it at all, you can exclude it.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
<Import-Package>
javax.inject;version=0.0.0,
!sun.misc;resolution=optional,!javax.persistence,!com.sun.jdi.*,
!com.microsoft.schemas.office.powerpoint,*
</Import-Packages>

Unresolved constraint in bundle suddenly in new version of JBossFuse

I have already searched for solution online but none of them has actually worked. I am moving from JBossFuse 6.2.1. to JbossFuse 6.3.0. This includes upgrading dependencies which I have managed, most of them. Right now I am stuck with this error:
Error executing command: Error starting bundles:
Unable to start bundle 390: Unresolved constraint in bundle pipeline-reception-ws-external-cxf [390]: Unable to resolve 390.0: missing requirement [390.0] osgi.wiring.package; (osgi.wiring.package=org.eclipse.jetty.http.ssl)
I am using maven-bundle-plugin which is configured this way:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Import-Package>
org.apache.camel.*;version="[${camel.range.start},${camel.range.end})",
ms.common.wsdl,template.velocity,org.eclipse.jetty.server,*
</Import-Package>
<Export-Package>
eu.unicorn.basse.ms.pipeline.reception.route.ws.external.cxf.*
</Export-Package>
<_removeheaders>Import-Service</_removeheaders>
</instructions>
</configuration>
</plugin>
I am not sure why this does not work if it works on older JbossFuse environment. Question is, how to solve this issue.
This error indicates that your environment does not contain a bundle which exports the package org.eclipse.jetty.http.ssl. As there is no version information in your package import it indicates that you also don't have a suitably bundled version of it in your bundle's build path (if you did then the maven-bundle-plugin would have found a version and added it to your import).
Either this requirement on org.eclipse.jetty.http.ssl is new to your bundle, or it was previously supplied by another bundle in Fuse 6.2.1 which is no longer present in Fuse 6.3.0.
In any event you need to start by fixing your bundle, either by putting the relevant parts of Jetty on the build path so that you get a version range on your import, or by removing the new dependency which has leaked into your bundle. Then, if needed, you can simply deploy the other bundles that your bundle requires.

Error While Building using Maven

I am trying to build the Mule 2.2.8 jars using m2e eclipe plugin.
I am able to build a few jars successfully.
But later I am getting this exception.Can anyone help me with this.?
The error description is as below:
Failed to execute goal org.apache.felix:maven-bundle-plugin:1.4.3:bundle (default-bundle) on project mule-module-spring-config: Error calculating classpath for project MavenProject: org.mule.modules:mule-module-spring-config:2.2.8 # C:\Users\Rohit Chopra\Documents\Mule_2.2.8\modules\spring-config\pom.xml: error in opening zip file
The pom.xml snippet where maven bundle plugin is present is like this:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
<configuration>
<obrRepository>NONE</obrRepository>
<instructions>
<!-- Each module can override these defaults in their osgi.properties file -->
<_include>-osgi.properties</_include>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-DocURL>${pom.url}</Bundle-DocURL>
<!-- Non-OSGi manifest entries -->
<!-- This would work if this issue gets closed: http://jira.codehaus.org/browse/MNG-1832 -->
<!--Build-Date>${mvn.timestamp.yyyy-MM-dd-HH:mm:ss}</Build-Date-->
<!-- include repository revision from buildnumber plugin -->
<Build-Revision>${buildNumber}</Build-Revision>
<Build-Date>${timestamp}</Build-Date>
</instructions>
</configuration>
</plugin>
Can you please suggest some fix for removing this error?
My first guess would be that you have a corrupted zip. Go to <root>\Documents and Settings\<username>\.m2 and find org/apache/felix/maven-bundle-plugin and remove it. Don't worry maven will download again.
I would also suggest to use Java 1.5 (IIRC that whats 2.2.8 required) and to put the source in a place without whitespaces in the path.

How to configure OSGI in IntelliJ when it's handled by Maven

I'm an OSGI newb.
I can really use any guidance I can get regarding IntelliJ IDEA / OSGI / Maven / Sling.
So the actual Felix plugin dies when I load it. Apparently it hasn't been maintained and is no longer compatible with the latest release by which I mean IntelliJ IDEA 13.
So I've configured the framework to felix-framework-4.2.1, and that seems to work fine. My greatest concern is that if I apply the OSGI facet to a bundle, the settings seem to indicate that it will change the bundle. Since we have this set up in Maven, I don't think we want this. The source of the facet seems to be the Osmorc plugin. When I used it before, there were complaints about some packages in maven that weren't OSGI enabled and the IDE wanted to point to a special Spring repository for OSGI enabled jar dependencies.
Since we are doing this in Maven, should I even bother with Osmorc? Is there a better way to manage OSGI in IntelliJ IDEA? It is handy knowing which packages are OSGI enabled but an error for that? Really? Specifically I am referring to "The package is not exported by the bundle dependencies" showing up on imports and annotations.
My personal observation with Intellij IDEA 13 is that the OSGI project inspector is slightly more aggressive when it comes to profiling your classes that utilize non-osgi exported classes. That being said, a way around this is by adjusting the inspector severity level. This enables you to use the same OSGI-based approach you were using in Intellij IDEA 12.
To do this, go into your project settings (on Mac: Command+,) and then navigate to the following node:
Inspections --> OSGI --> Package accessibility
Once selected, you'll be able to change the severity level from error to warning.
Performing this change is requisite on a few changes in your pom.xml:
<dependencies>
.
.
<dependency>
<groupId>com.pkg.name</groupId>
<artifactId>some-non-osgi-artifact</artifactId>
<version>0.1-EXAMPLE</version>
</dependency>
</dependencies>
<build>
<plugins>
.
.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>
you.know.what.goes.here
</Export-Package>
<Private-Package>you.know.what.goes.here</Private-Package>
<Import-Package>
*
</Import-Package>
<Embed-Dependency>some-non-osgi-artifact;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-StripGroup>true</Embed-StripGroup>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Hope this helps,
Ajay
I think your best bet currently is to use the maven bundle plugin to manage your imports and exports. This means intellij will simply see your bundles as maven projects. Still the correct jars should result. I handle OSGi bundles the same way in eclipse and it works fine.
I also read on the OSGi dev mailing list that there is a bndtools for intellij planned but this will for sure take a while.

install osgi dependencies via maven bundle and sling plugins

I have an osgi-bundle which is created by using the maven-bundle-plugin:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
The bundle is installed via the maven-sling-plugin.
I have a fasterxml.jackson dependency which exists as an osgi-bundle in my .m2 repo and acts as a dependency in my project.
How can I make maven deploy this dependency as an osgi-bundle as well?
At the moment I have to install it manually in my osgi-container.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.2</version>
</dependency>
EDIT:
Simplification:
How do I make maven realize that an osgi-bundle which I refer to as a dependency in my pom.xml shall be installed in the osgi-container along with the bundles that depend upon it?
You'll probably find its best to package your bundle as part of your application along with the /content, /apps portions of your application in the /apps/myapp/install folder will cause the libraries to be installed as bundles by the jcr installer provider.
There are a couple of ways of automating packaging/deployment of applications using maven described in these articles:
http://www.cognifide.com/blogs/cq/maven-plugin-automating-deployments-of-crx-cq-applications/
http://mkalugin-cq.blogspot.co.uk/2012/11/how-to-use-maven-project-to-create.html
http://labs.sixdimensions.com/blog/dklco/2012-05-03/introducing-cq-deploy-maven-plugin-deploying-cq-projects
http://dev.day.com/docs/en/cq/current/core/how_to/how_to_use_the_vlttool/vlt-mavenplugin.html
Alternatively, you could just use the CRXDE to place the bundles and then CRX Package Manager to test the approach, them move on to automated packaging later.
If you don't want to repackage the two OSGI bundles, you can use the sling maven plugin to install the jackson bundle directly
mvn org.apache.sling:maven-sling-plugin:install-file -Dsling.file=jackson-databind-2.2.2.jar

Resources