vendredi 22 mai 2015

AWS SDK in OSGi causing "Unable to resolve/Missing requirement" errors

I'm running into a really annoying issue while trying to get an OSGi program setup while also using the AWS SDK for Java. I'm using Eclipse with Bndtools and have created about as basic of a project as I can. All I have to do is import any part of the AWS SDK and I start getting a couple of errors that I can't seem to get around.

For starters, my test class is below:

package com.test;

import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;

import com.amazonaws.auth.BasicAWSCredentials;

public class Test extends DependencyActivatorBase {
    BasicAWSCredentials creds;
    public Test() {

    }
    @Override
    public void init(BundleContext arg0, DependencyManager arg1) throws Exception {
        arg1.add(createComponent().setInterface(Object.class.getName(), null).setImplementation(Test.class));
    }
}

I then create a Bundle descriptor and add com.test to the private packages section. Under the bnd.bnd I have osgi.cmpn,osgi.core,org.apache.felix.dependencymanager, and com.amazonaws.aws-java-sdk-osgi in the build path. The AWS SDK bundle I got from the Maven Repository and added all of the dependencies specified on that page to the local repo, as well. I then create a Run descriptor and it instantly gives the following error when attempting to resolve after adding myTest.testbundle to the run requirements:

Unable to resolve <<INITIAL>> version=null:
   missing requirement Require[osgi.identity]{}{filter=(osgi.identity=myTest.testbundle)} [caused by:
   Unable to resolve myTest.testbundle version=0.0.0:
   missing requirement Require[osgi.wiring.package]{}{filter=(&(osgi.wiring.package=com.amazonaws.auth)(version>=1.9.0)(!(version>=2.0.0)))} [caused by:
   Unable to resolve com.amazonaws.aws-java-sdk-osgi version=1.9.36:
   missing requirement Require[osgi.wiring.package]{}{filter=(osgi.wiring.package=com.sun.org.apache.xerces.internal.jaxp)}]]

I saw something in another post that stated that only java.* packages are included in the OSGi environment, so even though jaxp is part of the Java runtime library, I would have to specifically import it. So I looked for an OSGi bundle of the library and found it in the Maven Repository again, downloaded, and added it to my local repo. This fixes the resolve error, but now I get the following error when I click Run OSGi in the Run Descriptor:

! could not resolve the bundles: [com.amazonaws.aws-java-sdk-osgi-1.9.36Unresolved constraint in bundle com.amazonaws.aws-java-sdk-osgi [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (osgi.wiring.package=com.sun.org.apache.xerces.internal.jaxp) [caused by: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (osgi.wiring.package=org.w3c.dom.html)]
, myTest.testbundle-0.0.0Unresolved constraint in bundle myTest.testbundle [7]: Unable to resolve 7.0: missing requirement [7.0] osgi.wiring.package; (&(osgi.wiring.package=com.amazonaws.auth)(version>=1.9.0)(!(version>=2.0.0))) [caused by: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (osgi.wiring.package=com.sun.org.apache.xerces.internal.jaxp) [caused by: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (osgi.wiring.package=org.w3c.dom.html)]]
, org.apache.servicemix.bundles.jaxp-ri-1.4.5.1Unresolved constraint in bundle org.apache.servicemix.bundles.jaxp-ri [16]: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (osgi.wiring.package=org.w3c.dom.html)
]
! Failed to start bundle com.amazonaws.aws-java-sdk-osgi-1.9.36, exception Unresolved constraint in bundle com.amazonaws.aws-java-sdk-osgi [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (osgi.wiring.package=com.sun.org.apache.xerces.internal.jaxp) [caused by: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (osgi.wiring.package=org.w3c.dom.html)]
! Failed to start bundle myTest.testbundle-0.0.0, exception Unresolved constraint in bundle myTest.testbundle [7]: Unable to resolve 7.0: missing requirement [7.0] osgi.wiring.package; (&(osgi.wiring.package=com.amazonaws.auth)(version>=1.9.0)(!(version>=2.0.0))) [caused by: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (osgi.wiring.package=com.sun.org.apache.xerces.internal.jaxp) [caused by: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (osgi.wiring.package=org.w3c.dom.html)]]
! Failed to start bundle org.apache.servicemix.bundles.jaxp-ri-1.4.5.1, exception Unresolved constraint in bundle org.apache.servicemix.bundles.jaxp-ri [16]: Unable to resolve 16.0: missing requirement [16.0] osgi.wiring.package; (osgi.wiring.package=org.w3c.dom.html)

If I comment out the lines referring to the AWS components in the test code, the errors disappear. I'm about at my whits end trying to figure out what I need to do to fix this issue. The Run descriptor I'm using uses all default settings, so it runs on org.apache.felix.framework;version='[4,5)' but I changed it to run under a JavaSE-1.8 environment.




Aucun commentaire:

Enregistrer un commentaire