[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [equinox-dev] NPE from RegistryStrategyOSGI.onStop()
|
With the lazy start header, it works well. Thank you guys.
On 10/23/06, Oleg Besedin <obesedin@xxxxxxxxxx> wrote:
Hi Jason,
As Thomas said, in the example you attached
the bundle is not marked as "Eclipse-LazyStart". I believe if
you mark it (open manifest.mf -> Overview tab -> set "Activate
this plug-in when one of its classes is loaded"), it will solve the
shutdown order problem.
(You see the java.lang.NoClassDefFoundError
as your bundle tries to access a class from a bundle that was already stopped
during the shutdown process. In other words, that exception is caused by
an incorrect shutdown order.)
If this doesn't work, please open a
bug; be sure to include the launch configuration you are using.
Something else that you might find strange
now or later :-) :
One other point that might be confusing
about OSGi bundle startup is that bundles that were explicitly started
at some point will be started again on subsequent restarts.
For instance, let's say that the bundle
MyBundle doesn't have LazyStart specified and is not listed in any special
startup mechanism. Normally this bundle lies in a "resolved"
state. Let's say one day this bundle gets explicitly started either via
console or by another bundle. Eclipse will remember that MyBundle was started
and will start it behind the scene on the next startup.
I just thought to mention this in case
you are wondering why your bundle starts :-). If you ever started it explicitly,
it is cached in the configuration area; to clean that cache open your launch
configuration, switch to the "Configuration" tab; select "Clear
the configuration area before launching".
Hope this helps.
Sincerely,
Oleg Besedin
Oleg,
Thanks for you quick answer. I tried your suggestion but it didn't work
as you described. I added an activator class into MyBundle. MyBundle's
activator#start() is called after
org.eclipse.equinox.registry's. And so does the activator#stop().This is
even worse. Because I got another exception in MyBundle's activator#stop()
method.
java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IExtensionRegistry
at registry.test.Activator.stop(Activator.java:30)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$3.run
(BundleContextImpl.java:1032)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:1028)
at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker
(BundleHost.java:396)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:502)
at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1067)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:619)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:283)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown
(StartLevelManager.java:256)
at org.eclipse.osgi.framework.internal.core.SystemBundle.suspend(SystemBundle.java:190)
at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:537)
at org.eclipse.osgi.framework.internal.core.OSGi.shutdown(OSGi.java:61)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._shutdown(FrameworkCommandProvider.java:214)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke (Method.java:597)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:145)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(
FrameworkConsole.java:293)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:278)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java
:213)
at java.lang.Thread.run(Thread.java:619)
I attached the test bundle for your reference.
On 10/21/06, Oleg Besedin <
obesedin@xxxxxxxxxx> wrote:
Hi Jason,
The quick answer is that you need to stop your custom registry before org.eclipse.equinox.registry
bundle is stopped.
Normally bundles are stopped in the reverse order of dependency, i.e.,
if a bundle MyBundle depends on the org.eclipse.equinox.registry, then
MyBundle is stopped first on shutdown, then org.eclipse.equinox.registry.
So, normally, you could put the code to stop your custom registry into
MyBundle's activator#stop().
I *guess* that putting inappropriate bundle start levels could break the
shutdown order.
Thanks,
Oleg
Hi all,
I'm working on a project which is based on OSGi and equinox. The project
also includes equinox extension registry bundle. Since my extensions are
defined in files which are not in side the bundles, I need to load these
extensions into registry by IExtensionRegistry.addContribution() method.
And addContribution() method needs the master token which is under control
of equinox registry bundle and I can't get it, so I have to create my registry
instead of using the default registry. Here are what I have done.
1. Add "-Declipse.createRegistry=false"
into VM arguments. This will disable the default registry.
2. Create my extension registry
component and register it with declarative service spec. In the activate()
method I creat my OSGi strategy and registry. In the deactivate() method
I call IExtensionRegistry.stop() method to stop the registry.
3. Start my application
and the registry works well.
4. Shutdown the OSGi framework
by typing "shutdown" command in the console. org.eclipse.core.internal.registry.osgi.Activator.stop
() method is called and the bundle context is set to null. Then my registry
deactivate() method is called. I got java.lang.NullPointerException from
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.onStop(RegistryStrategyOSGI.java
:204) since the bundle context is null.
I wonder if there's any way I can work around. Thanks.
--
Best Regards,
Jason Hao _______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
--
Best Regards,
Jason Hao [attachment "registry.test.zip" deleted by Oleg Besedin/Ottawa/IBM]
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
--
Best Regards,
Jason Hao