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]

Reply via email to