[rules-users] org.drools.osgi.api.Activator.stop() - java.lang.IllegalStateException: The service has been unregistered

tkleszczynski t.kleszczynski at gmail.com
Wed Sep 12 06:01:11 EDT 2012


Hello, 
I noticed problem/bug with stopping bundle org.drools.api (knowledge-api).
Problem occurs when OSGi framework stops this bundle. Method
org.drools.osgi.api.Activator.stop() firstly invokes
this.serviceRegistry.unregister() and then this.registryTracker.close().
Unfortunately DroolsServiceTracker uses reference to service which has been
unregistered. 

I think this problem can be fixed by moving
this.serviceRegistry.unregister(); to end of
org.drools.osgi.api.Activator.stop() method, after code which stops service
trackers. Then service will be still registered during service trackers
closing. Maybe would be worth to create JIRA issue and fix it in next
version.

Drools version: 5.4.0.Final 
Equinox version: 3.7.0 
stacktrace from OSGi console:
Framework is launched.

id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.7.0.v20110524
1	ACTIVE      org.drools.api_5.4.0.Final
2	ACTIVE      com.springsource.org.xmlpull_1.1.4.c
3	ACTIVE      com.springsource.com.sun.msv.datatype_0.0.0.20060615
4	ACTIVE      com.springsource.com.sun.xml.bind_2.1.7
	            Fragments=12
5	ACTIVE      org.drools.core_5.4.0.Final
6	ACTIVE      org.apache.servicemix.bundles.protobuf-java_2.4.1.1
7	ACTIVE      com.springsource.javax.xml.bind_2.1.7
8	RESOLVED    com.springsource.org.apache.xerces_2.9.1
	            Master=19
9	ACTIVE      org.mvel2_2.1.0.drools16
10	ACTIVE      org.eclipse.jdt.core.compiler.batch_3.3.0
11	ACTIVE      org.drools.compiler_5.4.0.Final
12	RESOLVED    com.springsource.com.sun.xml.bind.jaxb1_2.1.7
	            Master=4
13	ACTIVE      com.springsource.com.sun.tools.xjc_2.1.7
14	ACTIVE      org.drools.internalapi_5.4.0.Final
15	ACTIVE      com.springsource.org.dom4j_1.6.1
16	ACTIVE      com.springsource.javax.xml.stream_1.0.1
17	ACTIVE      com.springsource.org.antlr_3.1.3
18	ACTIVE      com.springsource.org.jvnet.staxex_1.0.0
19	ACTIVE      com.springsource.org.apache.xmlcommons_1.3.4
	            Fragments=8
20	ACTIVE      com.springsource.com.sun.xml.fastinfoset_1.2.2
21	ACTIVE      com.springsource.org.relaxng.datatype_1.0.0
22	ACTIVE      com.springsource.com.thoughtworks.xstream_1.3.1
23	ACTIVE      com.springsource.javax.activation_1.1.1
24	ACTIVE      com.springsource.org.apache.xml.resolver_1.2.0

osgi> stop 1
unregistering : org.drools.io.impl.ResourceFactoryServiceImpl at 1d686c1 :
interface org.drools.io.ResourceFactoryService
org.osgi.framework.BundleException: Exception in
org.drools.osgi.api.Activator.stop() of bundle org.drools.api.
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:791)
	at
org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.stop(AbstractBundle.java:464)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.stop(AbstractBundle.java:456)
	at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._stop(FrameworkCommandProvider.java:361)
	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:209)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:155)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.runConsole(FrameworkConsole.java:140)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:104)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: The service has been
unregistered
	at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getReferenceImpl(ServiceRegistrationImpl.java:277)
	at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getReference(ServiceRegistrationImpl.java:266)
	at
org.drools.osgi.api.Activator$DroolsServiceTracker.removedService(Activator.java:115)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1006)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:352)
	at org.osgi.util.tracker.ServiceTracker.close(ServiceTracker.java:412)
	at org.drools.osgi.api.Activator.stop(Activator.java:67)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:771)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:764)
	... 13 more
Nested Exception:
java.lang.IllegalStateException: The service has been unregistered
	at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getReferenceImpl(ServiceRegistrationImpl.java:277)
	at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getReference(ServiceRegistrationImpl.java:266)
	at
org.drools.osgi.api.Activator$DroolsServiceTracker.removedService(Activator.java:115)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1006)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:352)
	at org.osgi.util.tracker.ServiceTracker.close(ServiceTracker.java:412)
	at org.drools.osgi.api.Activator.stop(Activator.java:67)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:771)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:764)
	at
org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.stop(AbstractBundle.java:464)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.stop(AbstractBundle.java:456)
	at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._stop(FrameworkCommandProvider.java:361)
	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:209)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:155)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.runConsole(FrameworkConsole.java:140)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:104)
	at java.lang.Thread.run(Thread.java:662)
Nested Exception:
java.lang.IllegalStateException: The service has been unregistered
	at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getReferenceImpl(ServiceRegistrationImpl.java:277)
	at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getReference(ServiceRegistrationImpl.java:266)
	at
org.drools.osgi.api.Activator$DroolsServiceTracker.removedService(Activator.java:115)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1006)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:352)
	at org.osgi.util.tracker.ServiceTracker.close(ServiceTracker.java:412)
	at org.drools.osgi.api.Activator.stop(Activator.java:67)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:771)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:764)
	at
org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.stop(AbstractBundle.java:464)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.stop(AbstractBundle.java:456)
	at
org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._stop(FrameworkCommandProvider.java:361)
	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:209)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:155)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.runConsole(FrameworkConsole.java:140)
	at
org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:104)
	at java.lang.Thread.run(Thread.java:662)





--
View this message in context: http://drools.46999.n3.nabble.com/org-drools-osgi-api-Activator-stop-java-lang-IllegalStateException-The-service-has-been-unregistered-tp4019701p4019702.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list