I am getting "Missing packages" exceptions when using 2.0M4 under KF OSGi.

I load:
    org.restlet.jar,   #22 then
    org.json.jar,    #23 then 
    org.restlet.ext.json.jar #24
with no error.

noting in the jar manifests

org.restlet.jar
    exports org.restlet.resource, etc
    it imports org.json   
    
org.json.jar
    exports nothing - it is a non-OSGi jar.
    
org.restlet.ext.json
    Export-Package  org.restlet.ext.json;uses:="org.restlet.resource, org.json" 
 
    Import-Package     org.json  org.restlet.resource & others
    and the jar [LIST] includes
    org/restlet/ext/json
        JsonConverter.class
        JsonRepresentation.class
    
I then start org.restlet.jar  (Activator class 
=org.restlet.engine.internal.Activator) #22
it resolves then returns from start.

I then start bundle #34 which uses Restlet.  Its jar says
Import-Package   org.osgi.framework;version="1.3.0",...,
org.restlet,...
org.restlet.resource, ...
org.restlet.ext.json,
org.json

During resolution, it is not able to find org.restlet.ext.json & org.json
and it throws exception:

ERROR    20090813 19:08:27 bid#34       - FrameworkEvent ERROR (
org.osgi.framework.BundleException: 
'Unable to resolve bundle: 
missing package(s) or can not resolve all of the them:
org.restlet.ext.json,
org.json).

It seems to me that no bundle is exporting org.json.

Can an OSGi expert help steer me through this. I am not an OSGi expert, but I 
see things being done differently here from how similar things were done by KF 
in porting GWT to OSGi and wonder if that relates to my Exceptions.  

I see the Restlet code tends to use the "uses" qualification in Export-Package 
clauses.  My limited understanding of "uses" is that it is required to help 
resolve when there are several versions of the same package in a framework and 
provides a way to enforce that all classes needing to share one version and 
class loader do so. My understanding is that it is not intended to help 
reference a non-osgi jar.  

To include a non-osgi jar, and looking at the KF GWT implementation, I see that 
they have a bundle include the non-osgi library bundle as part of the using 
OSGi bundle.  In the case I am looking at, org.restlet.ext.json.jar would 
include json.jar in org.restlet.ext.json.jar and then include a reference to it 
with Bundle-Classpath.

This is described in OSGi R4.1 doc at 3.8.1 Bundle Class Path:
"Intra bundle class path dependencies are declared in the Bundle-Classpath 
manifest header. This declaration allows a bundle to declare its embedded class 
path using one or more JAR files or directories that are contained in the 
bundle’s JAR file.  The Bundle-Classpath manifest header is a list of 
comma-separated file names. A file name can be  ... a path to a JAR file 
contained in the bundle’s JAR file."

The classpath entry would be something like:
Bundle-Classpath  .,json.jar

That bundle can then export the packages of json.jar making them available to 
all.  It is a wrapper.

Is org.restlet.ext.json intended to be the wrapper but not quite there yet or 
is there something else I am missing or need to look at?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2383503

Reply via email to