missing (&(osgi.ee=JavaSE)(version=1.8)) when embedding in org.apache.felix.framework

5,538 views
Skip to first unread message

open fokus

unread,
Sep 10, 2014, 5:49:22 PM9/10/14
to bndtool...@googlegroups.com
I am not sure if this problem is related to the way the MANIFEST is generated by bnd or if this is
a framework configuration problem (or something else). I am trying to install bundles into a felix framework instance and I get the following missing requirement error:

(&(osgi.ee=JavaSE)(version=1.8))

In my bundle's manifest, I have:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-2.3.0.201405100607

but the framework seem to provide this capability ( from webconsole ):

...
Provide-Capability: osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2", osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8"


So why is that requirement unsatisfied ?
Thanks,

Peter

Peter Kriens

unread,
Sep 11, 2014, 3:41:50 AM9/11/14
to bndtool...@googlegroups.com
Looks perfectly ok to ... Can you send the error and provide some context info like the framework you use?

Kind regards,

Peter Kriens

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

BJ Hargrave

unread,
Sep 11, 2014, 3:57:23 AM9/11/14
to bndtool...@googlegroups.com
Your capability should use version:List<Version> not version:List which is version:List<String>.
--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- 
BJ

Peter Kriens

unread,
Sep 11, 2014, 5:24:52 AM9/11/14
to bndtool...@googlegroups.com
What framework are you running on?

Kind regards,

Peter Kriens

open fokus

unread,
Sep 11, 2014, 6:02:15 AM9/11/14
to bndtool...@googlegroups.com
Dear Peter, BJ
Sorry, took some time because I wanted to build a self-contained example.
Framework is org.apache.felix.framework-4.2.1.jar

I want to build a host application with an embedded framework as plugin container.

Test Case outline:

@Before
public void setup() throws Exception {
/* basically:
           fwk = getFrameworkFactory(
                resourceRoot.resolve(EmbeddedFramework.FRAMEWORK_FACTORY_PATH))
                .newFramework(m);
        fwk.start();
*/
        efwk = new EmbeddedFramework(test_FRAMEWORK_FACTORY_PATH);
        fwk = efwk.createFramework();
    }

@Test
    public void list() throws Exception {
        Path repoAdmin = BND_DIR
                .resolve("localrepo/org.apache.felix.bundlerepository/org.apache.felix.bundlerepository-2.0.2.jar");

        Path resolver = BND_DIR
                .resolve("localrepo/org.apache.felix.resolver/org.apache.felix.resolver-1.0.0.jar");

    Path repoService = BND_DIR
                .resolve("releaserepo/base.impl.reposervice/base.impl.reposervice-1.0.21.jar");

    // more seed packages
    ...
    efwk.installBundles(asList(scr, repoAdmin, resolver, repoService, cmpn));
    efwk.startBundles();

repoService is a component that looks like this:

import org.apache.felix.bundlerepository.Reason;
import org.apache.felix.bundlerepository.RepositoryAdmin;
import org.apache.felix.bundlerepository.Resolver;
import org.apache.felix.bundlerepository.Resource;
...
@Component(immediate = true)
public class RepoService {
// got this with a service reference
 AtomicReference<RepositoryAdmin> repoAdmin = new AtomicReference<>();

    @Activate
    public void activate(BundleContext bctx) throws MalformedURLException,
            Exception {
        repoAdmin.get().addRepository(
                new URL("file:/home/p/kepler-osgi/cnf/releaserepo/index.xml"));
        repoAdmin.get().addRepository(
                new URL("file:/home/p/kepler-osgi/cnf/localrepo/index.xml"));

        Resolver resolver = repoAdmin.get().resolver();
        String resFilter = "(&(uri=*base.api*)(version=3.0.0))";

        Resource[] resources = repoAdmin.get().discoverResources(resFilter);
        for (Resource res : resources) {
            resolver.add(res);

            if (resolver.resolve()) {
                for (Resource depRes : resolver.getRequiredResources()) {
                    System.out.println("Deploying dependency: "
                            + depRes.getPresentationName() + " (" + depRes.getSymbolicName()
                            + ") " + depRes.getVersion());
                }
                resolver.deploy(START);
            } else {
                for (Reason reason : resolver.getUnsatisfiedRequirements()) {
                    System.out.println("missing " + reason.getRequirement().getFilter());
                }
            }
        }
    }

...

and base.api has the following MANIFEST

Export-Package: ....
Import-Package: ....

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

When I run the testcase list(), the reposervice component starts and I get a missing requirement:

missing (&(osgi.ee=JavaSE)(version=1.8))

From what I understand, this should be a capability of the framework

@BJ: the Provide-Capability I copied is the default setting of the felix framework 4.2.1, do you mean I need to change this ?

Thanks a lot, sorry if the code is too long , but I am really not sure where the problem is ...
Peter


BJ Hargrave

unread,
Sep 11, 2014, 6:17:49 AM9/11/14
to bndtool...@googlegroups.com
On September 11, 2014 at 6:02:15, open fokus (peter....@openfokus.org) wrote:
@BJ: the Provide-Capability I copied is the default setting of the felix framework 4.2.1, do you mean I need to change this ?

Sounds like Felix has improperly specified the osgi.ee capability if it is not version:List<Version>. If you fix it, does this solve your problem?


-- 
BJ

open fokus

unread,
Sep 11, 2014, 6:35:45 AM9/11/14
to bndtool...@googlegroups.com

--

Jan Winter

unread,
Sep 12, 2014, 7:30:52 AM9/12/14
to bndtool...@googlegroups.com
Hello,

If You have permission to update 'index.xml'? 

Then You could add '<directive name="resolution" value="optional"/>' to related <requirement>.

I had a similar problem in a previous past.

David Bosschaert

unread,
Sep 12, 2014, 8:27:22 AM9/12/14
to bndtool...@googlegroups.com
This property is defined by the OSGi core spec. It is defined in the
felix-svn/framework/src/main/resources/default.properties file.

Best regards,

David

Stuart McCulloch

unread,
Sep 12, 2014, 8:55:38 AM9/12/14
to bndtool...@googlegroups.com
default.properties in Felix 4.2.1 does use version:List<Version> for the osgi.ee capability … not sure why the <Version> part didn’t appear in webconsole, might be a rendering bug

eecap-1.8= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", \
 osgi.ee; osgi.ee="JavaSE"; version:List<Version>=“1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8”

ee-1.8=JavaSE-1.8,JavaSE-1.7,JavaSE-1.6,J2SE-1.5,J2SE-1.4,J2SE-1.3, \
 J2SE-1.2,JRE-1.1,JRE-1.0,OSGi/Minimum-1.2,OSGi/Minimum-1.1, \
 OSGi/Minimum-1.0

open fokus

unread,
Sep 12, 2014, 9:06:40 AM9/12/14
to bndtool...@googlegroups.com
Thanks David,

@BJ: I think default.properties is correctly defined as :

# New-style generic execution environment capabilities.
org.osgi.framework.system.capabilities= \
 ${eecap-${java.specification.version}}

eecap-1.8= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", \
 osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8"
...

So the problem doesn't seem to be the framework. I suspect (also based on Jan's comment) that the function:

org.apache.felix.bundlerepository.Resolver.resolve()

doesn't correctly handle the osgi.ee filter ( at least the way I use it , based on this: http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html#ApacheFelixOSGiBundleRepository-OBRServiceAPI

Because when I install the bundle that is reported to have a missing requirement by resolve() in the embedded framework it starts correctly and I get the services I expect. So for the moment, it seems that I have to ignore the presumably missing (&(osgi.ee=JavaSE)(version=1.8)) requirement.

I had a look at the bnd/bndtools code in the meantime and they don't use the felix resolver at all, bnd has its own resolver. So in the future , I am going to use bnd for the embedded framework resolver. But since I can't find no api doc for bnd, this is for some rainy days ...



Tanks to all
Peter

open fokus

unread,
Sep 12, 2014, 9:08:31 AM9/12/14
to bndtool...@googlegroups.com
Stuart, got your update right after I send my response, yes I think it's a rendering bug in the webconsole, the default.properties is correct.
Peter

Jan Winter

unread,
Sep 12, 2014, 5:19:23 PM9/12/14
to bndtool...@googlegroups.com
Hello, 

I found one related fact in 'org.apache.felix.bundlerepository-2.0.2/org.apache.felix.bundlerepository.impl.LocalResourceImpl.java'.
- declared 'osgi.ee' capabilities from framework-bundle will realized as 'ee=JavaSE-1.8' capability
- but the filter require 1 spitted capability (<java-ee-name> and <java-ee-version>) '(&(osgi.ee=JavaSE)(version=1.8))'

Here the patch who works for me:
85c85,86
<                     cap.addProperty(Capability.EXECUTIONENVIRONMENT, tokens.nextToken().trim());
---
>                     String eeValue = tokens.nextToken().trim();
> cap.addProperty(Capability.EXECUTIONENVIRONMENT, eeValue);
86a88,100
>
>                     String[] split = eeValue.split("-");
>                     switch (split.length) {
> case 2:
> String osgi_ee = "osgi." + Capability.EXECUTIONENVIRONMENT;
> CapabilityImpl cap2 = new CapabilityImpl(osgi_ee, new PropertyImpl[]{
> new PropertyImpl(osgi_ee, null, split[0]),
> new PropertyImpl("version", null, split[1])
> });
> addCapability(cap2);
> break;
> }

open fokus

unread,
Sep 13, 2014, 2:11:47 AM9/13/14
to bndtool...@googlegroups.com
HI Jan, thanks a lot for investigating, this then concludes that the resolver is the cause for the presumably missing requirement. I hope, I can soon use the bnd api directly from my app.
Peter

David Bosschaert

unread,
Sep 15, 2014, 8:44:51 AM9/15/14
to bndtool...@googlegroups.com
Hi Jan,

Would you like to file a bug in Felix JIRA with the patch so it can be
applied to the Felix OBR codebase?
https://issues.apache.org/jira/browse/FELIX

Thanks,

David

Jan Winter

unread,
Sep 16, 2014, 10:33:06 AM9/16/14
to bndtool...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages