Your headers look perfectly fine to me, but the Require-Bundle code hasn't
been checked in yet.  I chatted with Richard yesterday and he was about
finished so it shouldn't be too much longer.

Chris

On 1/30/07, John E. Conlon <[EMAIL PROTECTED]> wrote:

Hi Richard,

The slf4j logging framework is now being offered as OSGi bundles, but
the caveat is that slf4j is using 'Split Packages' and uses
Require-Bundles. Tried the latest build to test these bundles but can't
see all classes in the split packages.  I know you were working on
Required-Bundle - Is Require-Bundle operational in the framework yet?

Here is what the two sl4fj bundles look like:

Bundle (3.0) -  slf4j-api:
Export-Package: org.slf4j.spi,
  org.slf4j;partial=true;mandatory:=partial,
  org.slf4j.impl;partial=true;mandatory:=partial

Bundle (4.0) - slf4j-nop:
Require-Bundle: slf4j.api;visibility:=reexport
Export-Package: org.slf4j, org.slf4j.impl
Import-Package: org.slf4j.spi
(Note:
- contains classes on split packages org.slf4j and org.slf4j.impl.
- uses classes on org.slf4j, org.slf4j.impl, org.slf4j.spi)

As I understand Require-Bundle; a client bundle (5.0 in the runtime)
that imports org.sl4fj and org.slf4j.impl packages will get them from
the slf4j-nop Bundle (4.0)  which will have gotten them from bundle
(3.0).  Since the packages are both split-packages they contain a
superset of classes that are contained in both the sl4j-api (3.0) and
slf4j-nop (4.0) bundles.  As a separate import the org.slf4j.spi should
be imported by the slf4j-nop bundle (4.0) from bundle(3.0).

When I start the runtime here is what happens...

Wiring looks good: (I think?)
DEBUG: WIRE: 1.0 -> org.osgi.service.packageadmin -> 0
DEBUG: WIRE: 1.0 -> org.osgi.service.startlevel -> 0
DEBUG: WIRE: 1.0 -> org.ungoverned.osgi.service.shell -> 1.0
DEBUG: WIRE: 1.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 1.0 -> org.apache.felix.shell -> 1.0
DEBUG: WIRE: 2.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 2.0 -> org.apache.felix.shell -> 1.0
DEBUG: WIRE: 4.0 -> org.slf4j.spi -> 3.0
DEBUG: WIRE: 5.0 -> org.slf4j -> 4.0
DEBUG: WIRE: 5.0 -> org.slf4j.impl -> 4.0

But when my slf4j-osgi-test bundle (5.0) starts and the activator is
called I get:
java.lang.NoClassDefFoundError: org/slf4j/ILoggerFactory
        at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:65)
        at org.slf4j.osgi.test.Activator.<init>(Activator.java:36)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at java.lang.Class.newInstance0(Class.java:350)
        at java.lang.Class.newInstance(Class.java:303)
        at
org.apache.felix.framework.Felix.createBundleActivator(Felix.java:2914)
        at org.apache.felix.framework.Felix._startBundle(Felix.java:1293)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1239)
        at
org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:834)
        at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:256)
        at java.lang.Thread.run(Thread.java:595)

Note: That class is in the slf4j-nop bundle (4.0).
-> ps
START LEVEL 2
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (0.9.0.incubator-SNAPSHOT)
[   1] [Active     ] [    1] Apache Felix Shell Service
(0.9.0.incubator-SNAPSHOT)
[   2] [Active     ] [    1] Apache Felix Shell TUI
(0.9.0.incubator-SNAPSHOT)
[   3] [Active     ] [    2] slf4j-api (1.3.0.SNAPSHOT)
[   4] [Active     ] [    2] slf4j-nop (1.3.0.SNAPSHOT)
[   5] [Resolved   ] [    2] slf4j-osgi-test (1.3.0.SNAPSHOT)

It appears that all classes in package org.slf4j  of slf4j-nop bundle
(4.0) are being shadowed by org.slf4j in sl4j-api (3.0).

Are these bundles specifying the Required bundles and Import/Exports
correctly?

thanks for any insight,
John





Reply via email to