On 7/29/11 5:39, Quecas wrote:
Hi guys,
Thanks for the replies.
At this stage my head still has a couple of hairs left to pull out
:confused:.
My test implementation goes something like this - sorry for the long
explanation, I really tried to make it short :-D
1. I am using eclipse 3.7 with bndtools.
2. My workspace includes 4 OSGI enabled projects:
a. cnf
b. org.me.osgi.app1 (starts org.me.osgi.app1.plugincontainer,
org.me.osgi.app1.spi.service, org.me.osgi.app1)
c. org.me.osgi.app1.spi.service (defines an interface 'ServiceProvider'
as is exported)
d. org.me.osgi.app1.plugincontainer (launches a new osgi framework and
installs,starts bunbles found in a pre-defined dir)
3. The org.me.osgi.app1.plugincontainer package defines a BundleActivator
which is responsable for launching the new osgi framework
public final class FrameworkActivator implements BundleActivator {
private FrameworkFactory frameworkFactory;
private Framework framework;
@Override
public void start(BundleContext context) throws Exception {
Map<String,String> config = new HashMap<String, String>();
config.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "JavaSE-1.6");
config.put(Constants.FRAMEWORK_STORAGE_CLEAN,
Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
config.put(Constants.FRAMEWORK_STORAGE,
"/home/me/tests/osgi/cache");
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"org.me.osgi.app1.spi.service");
Assuming you are embedding the framework.jar file into your outer
bundle, to export the above package from the inner system bundle, it
needs to be on the class path of the outer bundle, since the system
bundle can only export stuff that is available from its class loader.
config.put(Constants.FRAMEWORK_BUNDLE_PARENT,
Constants.FRAMEWORK_BUNDLE_PARENT_EXT);
I'm not sure why you are setting this, but to be clear, this setting has
nothing to do with exporting stuff from the system bundle.
5 The MANIFEST.MF for fragment bundle
org.me.osgi.app1.plugincontainer.extension-1.0.0.jar contains the following
headers
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.me.osgi.app1.plugincontainer.extension
Bundle-SymbolicName: org.me.osgi.app1.plugincontainer.extension
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Fragment-Host: system.bundle; extension:=framework
Export-Package: org.me.osgi.app1.spi.service;version="1.0.0"
You shouldn't be using a system bundle extension at all in this case. I
am pretty sure they won't work in this case, because they assume the
class loader of the framework is a URLClassLoader derivative, but the
class loader of an embedded framework is a bundle class loader.
-> richard
6. Launching the outer framework (via eclipse) I get the following error:
Failed to start bundle org.me.osgi.app1.plugincontainer-1.0.0, exception
Activator start error in bundle org.me.osgi.app1.plugins.greetingservice
[6].
7. -> ps (inner framework)
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (3.0.4)
[ 1] [Active ] [ 1] Apache Felix Declarative Services (1.4.0)
[ 2] [Active ] [ 1] Apache Felix Shell Service (1.4.2)
[ 3] [Active ] [ 1] Apache Felix Shell TUI (1.4.1)
[ 4] [Active ] [ 1] osgi.cmpn (4.2.1.201001051203)
[ 5] [Resolved ] [ 1] org.me.osgi.app1.plugincontainer.extension
(1.0.0)
[ 6] [Resolved ] [ 1] org.me.osgi.app1.plugins.greetingservice
(1.0.0)
8. -> start 6
org.osgi.framework.BundleException: Activator start error in bundle
org.me.osgi.app1.plugins.greetingservice [6].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1869)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1739)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:922)
at
org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:114)
at
org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:286)
at
org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:184)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError:
org/me/osgi/app1/spi/service/ServiceProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1872)
at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:720)
at org.apache.felix.framework.ModuleImpl.access$300(ModuleImpl.java:73)
at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1733)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:638)
at
org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3660)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1817)
... 6 more
Caused by: java.lang.ClassNotFoundException:
org.me.osgi.app1.spi.service.ServiceProvider
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.apache.felix.framework.ExtensionManager$ExtensionManagerModule.getClassByDelegation(ExtensionManager.java:692)
at
org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)
at
org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1370)
at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:715)
at org.apache.felix.framework.ModuleImpl.access$300(ModuleImpl.java:73)
at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1733)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
java.lang.NoClassDefFoundError: org/me/osgi/app1/spi/service/ServiceProvider
I have tried other things, but this is how I understand it to be, of which
I'm definitely missing something in my understanding of things.
Thanks Again
Jorge
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]