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 <[email protected]> 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: > > > <Import-Package>!com.host.kernel.logger,*</Import-Package> > > > 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 <[email protected]>: > > > Thanks a lot Tommy for the detailed suggestion. It helps in a lot for me > 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 trying > to > > install GoldenlseyeStorageService bundle. And as soon as I try to install > > 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=com.host.kernel.logger)(version>=1.19.0)(!(version>=2.0.0))) > > * > > * > > * > > Below is the code:- > > * > > * > > public class TestOSGi { > > > > public static void main(String[] args) { > > > > try { > > FileUtils.deleteDirectory(new File("felix-cache")); > > FrameworkFactory frameworkFactory = > > ServiceLoader.load(FrameworkFactory.class).iterator().next(); > > > > Framework framework = frameworkFactory.newFramework(new > > HashMap<String, String>()); > > framework.start(); > > > > final BundleContext bundleContext = framework.getBundleContext(); > > final List<Bundle> installedBundles = new LinkedList<Bundle>(); > > > > BundleActivator b = new org.ops4j.pax.url.mvn.internal.Activator(); > > b.start(bundleContext); > > > > String localFilename = > > "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 wants > 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 problem. > > 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 > > > > <dependency> > > <groupId>com.host.soa</groupId> > > <artifactId>soaMerged</artifactId> > > <scope>compile</scope> > > <exclusions> > > <exclusion> > > <artifactId>axis2</artifactId> > > <groupId>org.apache</groupId> > > </exclusion> > > </exclusions> > > </dependency> > > > > And the above maven dependency is bringing in kernelMerged dependency in > > 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.. > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > <project > > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 > > http://maven.apache.org/xsd/maven-4.0.0.xsd" > > xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" > > http://www.w3.org/2001/XMLSchema-instance"> > > > > <modelVersion>4.0.0</modelVersion> > > <groupId>com.host.personalize.goldeneye</groupId> > > <artifactId>GoldeneyeStorageService</artifactId> > > <version>1.0.0</version> > > > > <packaging>bundle</packaging> > > <name>GoldeneyeStorageService</name> > > > > <properties> > > <singlePom>true</singlePom> > > </properties> > > <dependencies> > > <dependency> > > <groupId>junit</groupId> > > <artifactId>junit</artifactId> > > <scope>compile</scope> > > </dependency> > > <dependency> > > <groupId>com.host.soa</groupId> > > <artifactId>soaMerged</artifactId> > > <scope>compile</scope> > > <exclusions> > > <exclusion> > > <artifactId>axis2</artifactId> > > <groupId>org.apache</groupId> > > </exclusion> > > </exclusions> > > </dependency> > > </dependencies> > > <build> > > <sourceDirectory>src</sourceDirectory> > > <testSourceDirectory>test</testSourceDirectory> > > <outputDirectory>build/classes</outputDirectory> > > <testOutputDirectory>build/classes</testOutputDirectory> > > <resources> > > <resource> > > <directory>gen-meta-src</directory> > > </resource> > > <resource> > > <directory>meta-src</directory> > > </resource> > > <resource> > > <directory>src</directory> > > <excludes> > > <exclude>**/*.java</exclude> > > </excludes> > > </resource> > > <resource> > > <filtering>true</filtering> > > <directory>src/main/filtered-resources</directory> > > </resource> > > </resources> > > <testResources> > > <testResource> > > <directory>test</directory> > > <excludes> > > <exclude>**/*.java</exclude> > > </excludes> > > </testResource> > > </testResources> > > <plugins> > > <plugin> > > <groupId>org.codehaus.mojo</groupId> > > <artifactId>build-helper-maven-plugin</artifactId> > > <version>1.7</version> > > <executions> > > <execution> > > <id>add-source</id> > > <phase>generate-sources</phase> > > <goals> > > <goal>add-source</goal> > > </goals> > > <configuration> > > <sources> > > <source>src</source> > > <source>gen-src/client</source> > > </sources> > > </configuration> > > </execution> > > </executions> > > </plugin> > > <plugin> > > <groupId>org.apache.felix</groupId> > > <artifactId>maven-bundle-plugin</artifactId> > > <configuration> > > <manifestLocation>src/main/resources/META-INF</manifestLocation> > > <instructions> > > <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> > > <Bundle-Name>${pom.artifactId}</Bundle-Name> > > <Export-Package>{local-packages}</Export-Package> > > <Import-Package>*</Import-Package> > > > > > <Include-Resource>{maven-resources},build/classes/buildinfo.properties</Include-Resource> > > <X-Raptor-Pipeline-Handler></X-Raptor-Pipeline-Handler> > > </instructions> > > <executions> > > <execution> > > <id>default-bundle</id> > > <phase>compile</phase> > > <goals> > > <goal>bundle</goal> > > </goals> > > </execution> > > </executions> > > </configuration> > > </plugin> > > </plugins> > > </build> > > </project> > > > > If you can guide me step by step then it will be great for me to fix this > > problem.. Thanks for your time and help. > > > > > > > > > > > > > > *Raihan Jamal* > > > > > > On Sun, Aug 25, 2013 at 8:36 AM, Tommy Svensson <[email protected]> > wrote: > > > >> Hello Jamal, > >> > >> Both your mails seems to be the same thing. > >> > >> The following import: > >> > >> Import-Package: com.host.kernel.logger;version="[1.19,2)",... > >> > >> means that this package is not available in the bundle being started and > >> 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=com.host.kernel.logger)(version>=1.19.0)(!(version>=2.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 the > >> 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: > >> > >> > >> <Bundle-SymbolicName>GoldeneyeModellingFramework</Bundle-SymbolicName> > >> > >> > <Bundle-Activator>com.host.personalize.goldeneye.framework.activator.Activator</Bundle-Activator> > >> > >> I always specify: > >> > >> <Embed-Dependency>*;scope=compile</Embed-Dependency> > >> > >> which will embed all jars with compile scope. Those I don't want > embedded > >> but import instead I specify with > >> > >> <scope>provided</scope> > >> > >> 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 on > >> 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: > >> > >> … > >> <archive> > >> <manifestEntries> > >> > >> > <Bundle-ClassPath>.,lib/GoldeneyeStorageService-1.0.0.jar,...</Bundle-ClassPath> > >> </manifestEntries> > >> </archive> > >> … > >> > >> 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 not > >> 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 <[email protected]>: > >> > >>> 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=com.host.kernel.logger)(version>=1.19.0)(!(version>=2.0.0))) > >>> * > >>> > >>> The company that I am working for they have made there own logger code > >>> 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 other > >>> 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 = > >>> ServiceLoader.load(FrameworkFactory.class).iterator().next(); > >>> > >>> Framework framework = frameworkFactory.newFramework(new > >> HashMap<String, > >>> String>()); > >>> framework.start(); > >>> > >>> final BundleContext bundleContext = framework.getBundleContext(); > >>> final List<Bundle> installedBundles = new LinkedList<Bundle>(); > >>> > >>> BundleActivator b = new org.ops4j.pax.url.mvn.internal.Activator(); > >>> b.start(bundleContext); > >>> > >>> String localFilename = > >>> "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;use > >>> > >> s:="com.host.soaframework.common.exceptions,com.host.marketplace.servic > >>> es.storageservice,com.host.personalize.services.storage.consumer.ge > >>> n,com.host.personalize.services.storage.consumer,com.host.soaframew > >>> > >> ork.sif.service,com.host.marketplace.services,com.host.kernel.logger";v > >>> > >> ersion="1.0.0",com.host.marketplace.services.storageservice;uses:="java > >>> > >> x.xml.bind.annotation,com.host.marketplace.services,javax.activation";v > >>> ersion="1.0.0",com.host.personalize.services.storage.consumer;uses: > >>> ="javax.xml.ws > >> ,com.host.marketplace.services.storageservice";version="1 > >>> .0.0",com.host.personalize.services.storage.consumer.gen;uses:="com > >>> .host.soaframework.common.exceptions,com.host.personalize.services. > >>> > >> storage.consumer,com.host.soaframework.sif.impl.internal.service,com.eb > >>> ay.soaframework.sif.service,javax.xml.ws > >> ,com.host.marketplace.services. > >>> > >> storageservice,com.host.soaframework.common.types,com.host.soaframework > >>> > >> .common.impl.internal.schema,javax.xml.namespace,com.host.soaframework. > >>> common.registration";version="1.0.0" > >>> Import-Package: > >> com.host.kernel.logger;version="[1.19,2)",com.host.marke > >>> > >> tplace.services;version="[1.7,2)",com.host.soaframework.common.exceptio > >>> > >> ns;version="[1.4,2)",com.host.soaframework.common.impl.internal.schema; > >>> > >> version="[1.4,2)",com.host.soaframework.common.registration;version="[1 > >>> .4,2)",com.host.soaframework.common.types;version="[1.4,2)", > >> com.host.so > >>> > >> aframework.sif.impl.internal.service;version="[1.4,2)",com.host.soafram > >>> > >> ework.sif.service;version="[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\GoldenlseyeStorageService > >>> > >>> > >>> Can anyone help me with this? > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

