I have an application which uses OSGi and we are using the felix
framework. We are also using the equinox registry plugin and in the
past this has worked fine. But I was just updating the equinox bundles
and felix (from 2.0.4 to 3.2.2! - oops) and I ran into a problem. When
I shutdown the application I get the following exception:
ERROR: Bundle org.eclipse.equinox.registry [3] Error stopping bundle.
(java.lang.IllegalStateException: Can only add listeners while bundle is active
or activating.)
java.lang.IllegalStateException: Can only add listeners while bundle is active
or activating.
at org.apache.felix.framework.Felix.addServiceListener(Felix.java:2818)
at
org.apache.felix.framework.BundleContextImpl.addServiceListener(BundleContextImpl.java:246)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:308)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:273)
at
org.eclipse.core.internal.registry.osgi.RegistryProviderOSGI.getRegistry(RegistryProviderOSGI.java:35)
at
org.eclipse.core.runtime.RegistryFactory.getRegistry(RegistryFactory.java:72)
at
org.eclipse.core.internal.adapter.AdapterManagerListener.stop(AdapterManagerListener.java:106)
at
org.eclipse.core.internal.registry.osgi.Activator.stop(Activator.java:65)
at
org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:651)
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2278)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1215)
at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
at java.lang.Thread.run(Thread.java:662)
I am uncertain as to whether this is a felix issue, an equinox issue or
maybe my issue.
I can replicate this exception by
1. downloading the felix 3.2.2 framework
2. downloading and copying
org.eclipse.equinox.common_3.6.0.v20100503.jar,
org.eclipse.equinox.registry_3.5.0.v20100503.jar,
org.eclipse.equinox.supplement_1.3.0.v20100503.jar from
http://download.eclipse.org/equinox/drops/R-3.6-201006080911/index.php
3. (if you have done this more than once) making sure that the
common, supplement and registry plugins are uninstalled.
4. installing, resolving and starting them in the common, supplement,
registry order.
5. stopping the registry.
There is a "Could not parse XML contribution for..." error that my
application doesn't get but I think that this is a problem with xml
parsing that I have solved in one of my bundles.
Can you advise me?
Thanks,
-Timothy
[tredmond@smi-tredmond-li felix-framework-3.2.2]$ java -jar bin/felix.jar
____________________________
Welcome to Apache Felix Gogo
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (3.2.2)
1|Active | 1|Apache Felix Bundle Repository (1.6.2)
2|Active | 1|Apache Felix Gogo Command (0.8.0)
3|Active | 1|Apache Felix Gogo Runtime (0.8.0)
4|Active | 1|Apache Felix Gogo Shell (0.8.0)
g! ls *.jar
/home/tredmond/Downloads/felix-framework-3.2.2/org.eclipse.equinox.common_3.6.0.v20100503.jar
/home/tredmond/Downloads/felix-framework-3.2.2/org.eclipse.equinox.supplement_1.3.0.v20100503.jar
/home/tredmond/Downloads/felix-framework-3.2.2/org.eclipse.equinox.registry_3.5.0.v20100503.jar
g! install
file:/home/tredmond/Downloads/felix-framework-3.2.2/org.eclipse.equinox.common_3.6.0.v20100503.jar
Bundle ID: 24
g! install
file:/home/tredmond/Downloads/felix-framework-3.2.2/org.eclipse.equinox.supplement_1.3.0.v20100503.jar
Bundle ID: 25
g! install
file:/home/tredmond/Downloads/felix-framework-3.2.2/org.eclipse.equinox.registry_3.5.0.v20100503.jar
Bundle ID: 26
g! resolve 24
g! resolve 25
g! resolve 26
g! start 24
g! start 25
g! start 26
Error: Could not parse XML contribution for
"org.eclipse.equinox.registry//plugin.xml". Any contributed extensions and
extension points will be ignored.
g! stop 26
ERROR: Bundle org.eclipse.equinox.registry [26] Error stopping bundle.
(java.lang.IllegalStateException: Can only add listeners while bundle is active
or activating.)
java.lang.IllegalStateException: Can only add listeners while bundle is active
or activating.
at org.apache.felix.framework.Felix.addServiceListener(Felix.java:2818)
at
org.apache.felix.framework.BundleContextImpl.addServiceListener(BundleContextImpl.java:246)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:308)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:273)
at
org.eclipse.core.internal.registry.osgi.RegistryProviderOSGI.getRegistry(RegistryProviderOSGI.java:35)
at
org.eclipse.core.runtime.RegistryFactory.getRegistry(RegistryFactory.java:72)
at
org.eclipse.core.internal.adapter.AdapterManagerListener.stop(AdapterManagerListener.java:106)
at
org.eclipse.core.internal.registry.osgi.Activator.stop(Activator.java:65)
at
org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:651)
at org.apache.felix.framework.Felix.stopBundle(Felix.java:2278)
at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:963)
at org.apache.felix.gogo.command.Basic.stop(Basic.java:817)
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.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
at
org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:469)
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:395)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Console.run(Console.java:62)
at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
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.apache.felix.gogo.runtime.Reflective.method(Reflective.java:136)
at
org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:469)
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:395)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:662)
java.lang.IllegalStateException: Can only add listeners while bundle is active
or activating.
g! gosh: stopping framework
[tredmond@smi-tredmond-li felix-framework-3.2.2]$