Return-Path: X-Original-To: apmail-felix-users-archive@minotaur.apache.org Delivered-To: apmail-felix-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 542B810103 for ; Mon, 26 Aug 2013 19:34:06 +0000 (UTC) Received: (qmail 81255 invoked by uid 500); 26 Aug 2013 19:34:06 -0000 Delivered-To: apmail-felix-users-archive@felix.apache.org Received: (qmail 80833 invoked by uid 500); 26 Aug 2013 19:34:03 -0000 Mailing-List: contact users-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@felix.apache.org Delivered-To: mailing list users@felix.apache.org Received: (qmail 80751 invoked by uid 99); 26 Aug 2013 19:34:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Aug 2013 19:34:01 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jamalraihan@gmail.com designates 209.85.219.43 as permitted sender) Received: from [209.85.219.43] (HELO mail-oa0-f43.google.com) (209.85.219.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Aug 2013 19:33:56 +0000 Received: by mail-oa0-f43.google.com with SMTP id i10so4163647oag.30 for ; Mon, 26 Aug 2013 12:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=OmZY4+w9Dg+unue6XExGHWcTrDEutDkg35g8yTrJiAs=; b=X/no2Jwxp7jQNWHbEGcGAHFu2rEOTexqZsPXotVMsFt8rEiZfqJmleZ37u3pM1XRgk B18A92f7rx97ZVweX4Mi877CP4jEUjeQZuag0Wo/IZ/XwowtzePLmX1UeH+KIWuToQna m5vU3ns7I7thguq4Aq3iqH+yH9PQafE2lSf2iX62s9b2LqKk8JvmMvLkNqrld/mFrUsA 3UA/lyUvbmYkCJVhmbmVF1xtUeRDWZjUdCnFqJ1ctNH+5fw4m5pftXkuXV30KPG2o9Td lMb5k3d7Ogb4DatCZTG2Tukrv6lT/kbG+mCTRH2gnwhNCvLj/Lb2kC7GfhBLAYG4CloZ 7urw== X-Received: by 10.182.120.132 with SMTP id lc4mr15937580obb.7.1377545615838; Mon, 26 Aug 2013 12:33:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.60.130 with HTTP; Mon, 26 Aug 2013 12:33:15 -0700 (PDT) In-Reply-To: References: <67E551F0-B959-4726-ADE1-AC33AB7B2C23@natusoft.se> From: Raihan Jamal Date: Mon, 26 Aug 2013 12:33:15 -0700 Message-ID: Subject: Re: osgi.wiring.package issue with Apache Felix To: users@felix.apache.org Content-Type: multipart/alternative; boundary=089e0111bd801815d404e4ded5e3 X-Virus-Checked: Checked by ClamAV on apache.org --089e0111bd801815d404e4ded5e3 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hello Tommy, It's not a unit test and I need these packages to be used in my code. And I am still facing this issue. What's the best you think to overcome this issue? *Raihan Jamal* On Mon, Aug 26, 2013 at 9:38 AM, Tommy Svensson wrote: > Hello again, > > Since it is a unit test that fails it means that the code actually > compiles or you would not get to the test. Thereby I conclude that the > dependency not being resolved is actually not needed. I would try to make > the following change to the maven-bundle-plugin config in your pom: > > > !com.host.kernel.logger,* > > > I've just learned something new myself by reading the BND documentatation= : > You can exclude packages by prefixing a package with "!" ! > > /Tommy > > 25 aug 2013 kl. 23:37 skrev Raihan Jamal : > > > Thanks a lot Tommy for the detailed suggestion. It helps in a lot for m= e > to > > understand few things. As I am new to OSGi world so little bit confuse > now.. > > > > Let us talk about this example now by which if I am able to solve the > > problem then I would be able to solve my other problems too.. Below is = my > > code in which I am able to start the OSGi framework and then I am tryin= g > to > > install GoldenlseyeStorageService bundle. And as soon as I try to insta= ll > > the bundle, I always get the exception as I told you in my previous > email . > > > > *Unresolved constraint in bundle GoldenlseyeStorageService [1]: Unable = to > > resolve 1.0: missing requirement [1.0] osgi.wiring.package; > > > (&(osgi.wiring.package=3Dcom.host.kernel.logger)(version>=3D1.19.0)(!(ver= sion>=3D2.0.0))) > > * > > * > > * > > Below is the code:- > > * > > * > > public class TestOSGi { > > > > public static void main(String[] args) { > > > > try { > > FileUtils.deleteDirectory(new File("felix-cache")); > > FrameworkFactory frameworkFactory =3D > > ServiceLoader.load(FrameworkFactory.class).iterator().next(); > > > > Framework framework =3D frameworkFactory.newFramework(new > > HashMap()); > > framework.start(); > > > > final BundleContext bundleContext =3D framework.getBundleContext(); > > final List installedBundles =3D new LinkedList(); > > > > BundleActivator b =3D new org.ops4j.pax.url.mvn.internal.Activator(= ); > > b.start(bundleContext); > > > > String localFilename =3D > > "file:C:\\Storage\\GoldenlseyeStorageService-1.0.0.jar"; > > > > installedBundles.add(bundleContext.installBundle(localFilename)); > > > > for (Bundle bundle : installedBundles) { > > bundle.start(); // this line throws me an exception > > } > > > > } catch (IOException e) { > > e.printStackTrace(); > > } catch (BundleException e) { > > e.printStackTrace(); > > } catch (Exception e) { > > e.printStackTrace(); > > } > > } > > } > > > > > > Now as you mention that the error mean is - the package the bundle want= s > to > > import is not being exported by *any other bundle (which bundle are we > > talking about here?)*, and thus cannot be imported. So here what I am > > supposed to do? What should I do here to fix the problem? > > > > Bcoz, I am installing only one bundle here which is bringing other > > dependencies and I am not sure what I should do here to fix this proble= m. > > As I am supposed to use lot of our company specific dependencies in my > > pom.xml file.. > > > > The bundle (*GoldenlseyeStorageService *) that I am trying to install > > depends on this maven dependency in its pom.xml file > > > > > > com.host.soa > > soaMerged > > compile > > > > > > axis2 > > org.apache > > > > > > > > > > And the above maven dependency is bringing in kernelMerged dependency i= n > > which this package is there- *com.host.kernel.logger. * > > * > > * > > And I am supposed to use this package in my code.. > > > > Now I believe the suggestions you gave me is- > > > > 1) I should install kernelMerged jar as a Bundle before installing * > > GoldenlseyeStorageService* , to solve this problem? Right? > > > > Below is my full pom.xml file for *GoldenlseyeStorageService *bundle > which > > is what I am trying to install.. > > > > > > > > > xsi:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 > > http://maven.apache.org/xsd/maven-4.0.0.xsd" > > xmlns=3D"http://maven.apache.org/POM/4.0.0" xmlns:xsi=3D" > > http://www.w3.org/2001/XMLSchema-instance"> > > > > 4.0.0 > > com.host.personalize.goldeneye > > GoldeneyeStorageService > > 1.0.0 > > > > bundle > > GoldeneyeStorageService > > > > > > true > > > > > > > > junit > > junit > > compile > > > > > > com.host.soa > > soaMerged > > compile > > > > > > axis2 > > org.apache > > > > > > > > > > > > src > > test > > build/classes > > build/classes > > > > > > gen-meta-src > > > > > > meta-src > > > > > > src > > > > **/*.java > > > > > > > > true > > src/main/filtered-resources > > > > > > > > > > test > > > > **/*.java > > > > > > > > > > > > org.codehaus.mojo > > build-helper-maven-plugin > > 1.7 > > > > > > add-source > > generate-sources > > > > add-source > > > > > > > > src > > gen-src/client > > > > > > > > > > > > > > org.apache.felix > > maven-bundle-plugin > > > > src/main/resources/META-INF > > > > ${pom.artifactId} > > ${pom.artifactId} > > {local-packages} > > * > > > > > {maven-resources},build/classes/buildinfo.properties > > > > > > > > > > default-bundle > > compile > > > > bundle > > > > > > > > > > > > > > > > > > > > If you can guide me step by step then it will be great for me to fix th= is > > problem.. Thanks for your time and help. > > > > > > > > > > > > > > *Raihan Jamal* > > > > > > On Sun, Aug 25, 2013 at 8:36 AM, Tommy Svensson > wrote: > > > >> Hello Jamal, > >> > >> Both your mails seems to be the same thing. > >> > >> The following import: > >> > >> Import-Package: com.host.kernel.logger;version=3D"[1.19,2)",... > >> > >> means that this package is not available in the bundle being started a= nd > >> needs to be imported from another bundle exporting this package. > >> > >> The following error message: > >> > >> Unresolved constraint in bundle GoldenlseyeStorageService [1]: > >> Unable > >> to resolve 1.0: missing requirement [1.0] osgi.wiring.package; > >> > >> > (&(osgi.wiring.package=3Dcom.host.kernel.logger)(version>=3D1.19.0)(!(ver= sion>=3D2.0.0))) > >> > >> says the the package the bundle wants to import is not being exported = by > >> any other bundle, and thus cannot be imported. > >> > >> There are 2 ways to solve this: > >> > >> 1) Another bundle exporting this package needs to be deployed. > >> > >> 2) A jar containing this package needs to be included/embeded within t= he > >> bundle instead of being imported from other bundle. > >> > >> Also note that a mismatch in version number of imported package and > >> exported package will not resolve! > >> > >> From the pom in your other mail I see you have several dependencies. > Only > >> one of them have a scope specified (compile), but if I remember > correctly > >> no scope specification is the same as "compile". I'm also unsure what > the > >> defaults are for the "maven-bundle-plugin", you only specify the > following > >> instructions: > >> > >> > >> GoldeneyeModellingFramework > >> > >> > com.host.personalize.goldeneye.framework.activator.Acti= vator > >> > >> I always specify: > >> > >> *;scope=3Dcompile > >> > >> which will embed all jars with compile scope. Those I don't want > embedded > >> but import instead I specify with > >> > >> provided > >> > >> Again, I don't know the default behavior if your dependencies gets > sucked > >> into your bundle or not. In my experience when you have dependencies o= n > >> frameworks the framework jars can contain dependencies to things you > don't > >> use and don't need, but an "Import" will be generated by the > >> maven-bundle-plugin. I have found no good way to handle those cases > other > >> than not use the maven-bundle-plugin more than once and then edit an > manage > >> the MANIFEST.MF manually. > >> > >> Also note that if your dependencies are included in your bundle, you > also > >> need to specify them in the "Bundle-Classpath". Example: > >> > >> =85 > >> > >> > >> > >> > .,lib/GoldeneyeStorageService-1.0.0.jar,... > >> > >> > >> =85 > >> > >> The maven-bundle-plugin (or underlaying BND) will try to import any > >> referenced package not part of the bundle internal classpath. I see no > >> Bundle-ClassPath specifications in your examples. > >> > >> In either case **you have dependencies that the server (felix) does no= t > >> know about.**, or possible have not been deployed yet, i.e things are > >> deployed in the wrong order. I have not used Felix directly, I use it > >> through glassfish. Glassfish does a reasonable good resolve of startup > >> order and redeploy later on failure. If that is a feature of Glassfish > or > >> Felix I don't know. > >> > >> Regards, > >> Tommy Svensson > >> > >> > >> 24 aug 2013 kl. 10:52 skrev Raihan Jamal : > >> > >>> I have successfullly started an OSGi framework (Apache Felix). Now I > was > >>> trying to start and install and OSGi bundle. But as soon as I try > >> starting > >>> the OSGI bundle, I always get this below exception- > >>> > >>> * Unresolved constraint in bundle GoldenlseyeStorageService [1]: > >> Unable > >>> to resolve 1.0: missing requirement [1.0] osgi.wiring.package; > >>> > >> > (&(osgi.wiring.package=3Dcom.host.kernel.logger)(version>=3D1.19.0)(!(ver= sion>=3D2.0.0))) > >>> * > >>> > >>> The company that I am working for they have made there own logger cod= e > >>> which is extending Apache Log4j. And this package > >> `com.host.kernel.logger` > >>> is coming from there jar file. Meaning my bundle is depending on this > jar > >>> maven dependency somehow. And I am not sure how can I fix the above > >>> exception as it might be possible, I might need to depend on some oth= er > >>> maven dependency of our company specific that is stored in our own > >>> repository. > >>> Below is my simple code which is starting the OSGi framewok and then > >>> trying to install/start the bundle- > >>> > >>> import java.io.File; > >>> > >>> import org.apache.tomcat.util.http.fileupload.FileUtils; > >>> import org.osgi.framework.Bundle; > >>> import org.osgi.framework.BundleActivator; > >>> import org.osgi.framework.BundleContext; > >>> import org.osgi.framework.BundleException; > >>> import org.osgi.framework.launch.Framework; > >>> import org.osgi.framework.launch.FrameworkFactory; > >>> > >>> public class TestOSGi { > >>> > >>> public static void main(String[] args) { > >>> > >>> try { > >>> FileUtils.deleteDirectory(new File("felix-cache")); > >>> FrameworkFactory frameworkFactory =3D > >>> ServiceLoader.load(FrameworkFactory.class).iterator().next(); > >>> > >>> Framework framework =3D frameworkFactory.newFramework(new > >> HashMap >>> String>()); > >>> framework.start(); > >>> > >>> final BundleContext bundleContext =3D framework.getBundleContext(); > >>> final List installedBundles =3D new LinkedList(); > >>> > >>> BundleActivator b =3D new org.ops4j.pax.url.mvn.internal.Activator(= ); > >>> b.start(bundleContext); > >>> > >>> String localFilename =3D > >>> "file:C:\\Storage\\GoldenlseyeStorageService-1.0.0.jar"; > >>> > >>> installedBundles.add(bundleContext.installBundle(localFilename)); > >>> > >>> for (Bundle bundle : installedBundles) { > >>> bundle.start(); > >>> } > >>> > >>> } catch (IOException e) { > >>> e.printStackTrace(); > >>> } catch (BundleException e) { > >>> e.printStackTrace(); > >>> } catch (Exception e) { > >>> e.printStackTrace(); > >>> } > >>> > >>> } > >>> } > >>> Below is the manifest file for my `GoldenlseyeStorageService` bundle > >> that I > >>> am trying to install- > >>> > >>> Manifest-Version: 1.0 > >>> Bnd-LastModified: 1377333824248 > >>> Build-Jdk: 1.6.0_26 > >>> Built-By: rjamal > >>> Bundle-Description: Managed dependencies and plugins across all > >> Raptor a > >>> pplications. > >>> Bundle-ManifestVersion: 2 > >>> Bundle-Name: GoldenlseyeStorageService > >>> Bundle-SymbolicName: GoldenlseyeStorageService > >>> Bundle-Version: 1.0.0 > >>> Created-By: Apache Maven Bundle Plugin > >>> Export-Package: com.host.domain.sharedpersonalize.storageservice;us= e > >>> > >> s:=3D"com.host.soaframework.common.exceptions,com.host.marketplace.ser= vic > >>> es.storageservice,com.host.personalize.services.storage.consumer.g= e > >>> n,com.host.personalize.services.storage.consumer,com.host.soaframe= w > >>> > >> ork.sif.service,com.host.marketplace.services,com.host.kernel.logger";= v > >>> > >> ersion=3D"1.0.0",com.host.marketplace.services.storageservice;uses:=3D= "java > >>> > >> x.xml.bind.annotation,com.host.marketplace.services,javax.activation";= v > >>> ersion=3D"1.0.0",com.host.personalize.services.storage.consumer;us= es: > >>> =3D"javax.xml.ws > >> ,com.host.marketplace.services.storageservice";version=3D"1 > >>> .0.0",com.host.personalize.services.storage.consumer.gen;uses:=3D"= com > >>> .host.soaframework.common.exceptions,com.host.personalize.services= . > >>> > >> storage.consumer,com.host.soaframework.sif.impl.internal.service,com.e= b > >>> ay.soaframework.sif.service,javax.xml.ws > >> ,com.host.marketplace.services. > >>> > >> storageservice,com.host.soaframework.common.types,com.host.soaframewor= k > >>> > >> .common.impl.internal.schema,javax.xml.namespace,com.host.soaframework= . > >>> common.registration";version=3D"1.0.0" > >>> Import-Package: > >> com.host.kernel.logger;version=3D"[1.19,2)",com.host.marke > >>> > >> tplace.services;version=3D"[1.7,2)",com.host.soaframework.common.excep= tio > >>> > >> ns;version=3D"[1.4,2)",com.host.soaframework.common.impl.internal.sche= ma; > >>> > >> version=3D"[1.4,2)",com.host.soaframework.common.registration;version= =3D"[1 > >>> .4,2)",com.host.soaframework.common.types;version=3D"[1.4,2)", > >> com.host.so > >>> > >> aframework.sif.impl.internal.service;version=3D"[1.4,2)",com.host.soaf= ram > >>> > >> ework.sif.service;version=3D"[1.4,2)",javax.activation,javax.xml.bind.= ann > >>> otation,javax.xml.namespace,javax.xml.ws > >>> ServicesURLStrategyVersion: 1.0.0-RELEASE > >>> Tool: Bnd-1.50.0 > >>> X-Raptor-Source-Dir: > >>> S:\GitViews\GoldenlseyeStream\GoldenlseyeStorageServic > >>> > >>> > >> > e/src/main/webapp,S:\GitViews\GoldenlseyeStream\GoldenlseyeStorageService= / > >>> > >>> > >> > src/main/resources,S:\GitViews\GoldenlseyeStream\GoldenlseyeStorageServic= e > >>> > >>> > >>> Can anyone help me with this? > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org > >> For additional commands, e-mail: users-help@felix.apache.org > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org > For additional commands, e-mail: users-help@felix.apache.org > > --089e0111bd801815d404e4ded5e3--