as I understand it, Felix does not yet support bundle fragments:
http://issues.apache.org/jira/browse/FELIX-29
which would explain why your code works on other R4 frameworks.
On 25/10/2007, Pierre De Rop <[EMAIL PROTECTED]> wrote:
> Hello community;
>
> I am facing an issue concerning Felix, Split packages and Fragment bundles.
> Here is my use case:
>
> 1/ We have some bundles with (unfortunately) some esoteric "split packages"
> which are not supported by OSGI.
> For instance:
>
> b1.jar exports package "com.p" with com.p.C1
> b2.jar exports package "com.p" with com.p.C2
> and:
> class com.p.C1 instantiates the com.p.C2
>
> 2/ In order to solve this problem, we could incorporate b1.jar and b2.jar
> into one "big.jar" with "Bundle-ClassPath: b1.jar, b2.jar",
> but we can't dot that (for some reasons not exposed here ...).
>
> 3/ Now, I am trying to use Fragments in order to solve the split package
> issue. It would be great if someone could have a look to the
> following sample code because it does not work with Felix 1.0.1, but it
> works properly with Knopflerfish and Equinox !
>
> Here is my sample code: the fraghost.jar loads a class from frag1.jar,
> which itself loads a class from frag2.jar ...
>
> Bundle "fraghost.jar":
>
> MANIFEST for fraghost.jar:
> ------------------------------------
>
>
> Manifest-Version: 1.0
> Created-By: 1.5.0_10 (Sun Microsystems Inc.)
> Bundle-Name: FragHost
> Bundle-SymbolicName: FragHost
> Bundle-ManifestVersion: 2
> Bundle-Version: 1.0.0
> Bundle-Activator: com.test.fraghost.FragHost
> Import-Package: org.osgi.framework
>
> Class com.test.fraghost.FragHost from fraghost.jar:
> ----------------------------------------------------------------
>
>
> public class FragHost implements BundleActivator {
> public void start(BundleContext context) throws Exception {
> out.println("FragHost is instantiating com.test.frag.Frag1 from
> frag1.jar ...");
> Runnable frag1 = (Runnable)
> getClass().getClassLoader().loadClass("com.test.frag.Frag1").newInstance();
> frag1.run();
> }
>
> public void stop(BundleContext context) throws Exception {
> out.println("Stopping FragHost");
> }
> }
>
> Bundle "frag1.jar":
>
>
> MANIFEST for frag1.jar:
> ---------------------------------
>
>
> Manifest-Version: 1.0
> Created-By: 1.5.0_10 (Sun Microsystems Inc.)
> Bundle-Name: Frag1
> Bundle-SymbolicName: Frag1
> Bundle-ManifestVersion: 2
> Fragment-Host: FragHost
>
> Class com/test/frag/Frag1.java from frag1.jar:
> ---------------------------------------------------------
>
>
> public class Frag1 implements Runnable {
> public Frag1() {
> out.println("In Frag1 constructor");
> }
>
> public void run() {
> try {
> out.println("Frag1 is instantiating Frag2 ...");
> Runnable frag2 = (Runnable)
> Class.forName("com.test.frag.Frag2").newInstance();
> frag2.run();
> } catch (Throwable t) {
> t.printStackTrace();
> }
> }
> }
>
> Bundle "frag2.jar":
>
>
> MANIFEST for frag2.jar:
> ---------------------------------
>
>
> Manifest-Version: 1.0
> Created-By: 1.5.0_10 (Sun Microsystems Inc.)
> Bundle-Name: Frag2
> Bundle-SymbolicName: Frag2
> Bundle-ManifestVersion: 2
> Fragment-Host: FragHost
>
> Class com/test/frag/Frag2.java from frag2.jar:
> ---------------------------------------------------------
>
>
> public class Frag2 implements Runnable {
> public Frag2() {
> out.println("In Frag2 constructor");
> }
>
> public void run() {
> try {
> out.println("In Frag2.run ...");
> } catch (Throwable t) {
> t.printStackTrace();
> }
> }
> }
>
> Running these bundles with Felix 1.0.1, I have the following exception:
>
> FragHost is instantiating com.test.frag.Frag1 from frag1.jar ...
> ERROR: Error starting file:bundle/fraghost.jar
> (org.osgi.framework.BundleException: Activator start error.)
> java.lang.ClassNotFoundException: *** Class 'com.test.frag.Frag1' was not
> found. Bundle 6 does not import package 'com.test.frag', nor is the package
> exported by any other bundle or available from the system class loader. ***
> at
> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:184)
> at
> org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(R4SearchPolicy.java:45)
> at
> org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(ContentClassLoader.java:75)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at com.test.fraghost.FragHost.start(FragHost.java:13)
> at
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:589)
> at org.apache.felix.framework.Felix._startBundle(Felix.java:1536)
> at org.apache.felix.framework.Felix.startBundle(Felix.java:1470)
> at
> org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1065)
> at
> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:258)
> at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.ClassNotFoundException: com.test.frag.Frag1
> at
> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource(R4SearchPolicyCore.java:412)
> at
> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:175)
> ... 10 more
>
> -> ps
> START LEVEL 1
> ID State Level Name
> [ 0] [Active ] [ 0] System Bundle (1.0.1)
> [ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.0)
> [ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.0)
> [ 3] [Active ] [ 1] osgi (4.0)
> [ 4] [Active ] [ 1] Frag1
> [ 5] [Active ] [ 1] Frag2
> [ 6] [Resolved ] [ 1] FragHost (1.0.0)
>
>
>
> Thanks for your help;
> Pierre.
>
>
>
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED] For additional
> commands, e-mail: [EMAIL PROTECTED]
--
Cheers, Stuart
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]