You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by "adrian.trenaman" <ad...@googlemail.com> on 2010/09/19 12:47:43 UTC

Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Hi there,

Have been doing some work on my Karaf archive deployer, which is working
nicely -except- when I shut down the Karaf instance: I see this nasty stack
trace. I've stepped through right to the Felix code and it seems that after
the unregister of my 'kar:' url handler service, the runtime tries to
register it again (why?!) and then this fails because the bundle in question
(org.apache.karaf.deployer.kar) is in a Stopping state - hence the
'IllegalStateException'.

I'll keep banging my head against this, but I'm keen to know if anyone else
out there has seen this or might have an idea of what I've done wrong. BTW,
I've based all my deployer code on the existing code for the features and
blueprints deployers.

Thanks in advance,
Ade.

---

java.lang.IllegalStateException: Can only register services while bundle is
active or activating
	at org.apache.felix.framework.Felix.registerService(Felix.java:2817)
	at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:388)
	at
org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:166)
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:596)
	at
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:393)
	at
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceRemoved(AbstractServiceReferenceRecipe.java:385)
	at
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:355)
	at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:864)
	at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:732)
	at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
	at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3726)
	at org.apache.felix.framework.Felix.access$000(Felix.java:80)
	at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:717)
	at
org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:135)
	at
org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:129)
	at
org.apache.aries.blueprint.container.ServiceRecipe.unregister(ServiceRecipe.java:183)
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.unregisterServices(BlueprintContainerImpl.java:657)
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.destroy(BlueprintContainerImpl.java:806)
	at
org.apache.aries.blueprint.container.BlueprintExtender.destroyContext(BlueprintExtender.java:204)
	at
org.apache.aries.blueprint.container.BlueprintExtender.bundleChanged(BlueprintExtender.java:196)
	at
org.apache.aries.blueprint.container.BlueprintExtender$BlueprintBundleTrackerCustomizer.modifiedBundle(BlueprintExtender.java:385)
	at
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
	at
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
	at
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:800)
	at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:728)
	at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3715)
	at org.apache.felix.framework.Felix.stopBundle(Felix.java:2180)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1172)
	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
	at java.lang.Thread.run(Thread.java:637)

-- 
View this message in context: http://karaf.922171.n3.nabble.com/Shutting-down-Karaf-I-get-an-IllegalStateException-Can-only-register-services-while-bundle-is-active-tp1523512p1523512.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Posted by Adrian Trenaman <TR...@progress.com>.
Thanks Guillaume,

Not sure if I can reproduce any more though: since I moved my code to use the ArtifactListener I don't get the error (!)



----- Original Message -----
From: Guillaume Nodet [mailto:gnodet@gmail.com]
Sent: Thursday, September 23, 2010 03:00 AM
To: dev@karaf.apache.org <de...@karaf.apache.org>
Subject: Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Btw, I've raised https://issues.apache.org/jira/browse/ARIES-424 for
this problem.

On Sun, Sep 19, 2010 at 23:02, adrian.trenaman
<ad...@googlemail.com> wrote:
>
> Patch now up on KARAF-151. Would be grateful if someone could review and give
> feedback or commit!
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Shutting-down-Karaf-I-get-an-IllegalStateException-Can-only-register-services-while-bundle-is-active-tp1523512p1525724.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Posted by Guillaume Nodet <gn...@gmail.com>.
Btw, I've raised https://issues.apache.org/jira/browse/ARIES-424 for
this problem.

On Sun, Sep 19, 2010 at 23:02, adrian.trenaman
<ad...@googlemail.com> wrote:
>
> Patch now up on KARAF-151. Would be grateful if someone could review and give
> feedback or commit!
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Shutting-down-Karaf-I-get-an-IllegalStateException-Can-only-register-services-while-bundle-is-active-tp1523512p1525724.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Posted by "adrian.trenaman" <ad...@googlemail.com>.
Patch now up on KARAF-151. Would be grateful if someone could review and give
feedback or commit! 
-- 
View this message in context: http://karaf.922171.n3.nabble.com/Shutting-down-Karaf-I-get-an-IllegalStateException-Can-only-register-services-while-bundle-is-active-tp1523512p1525724.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Posted by Guillaume Nodet <gn...@gmail.com>.
Yes, please go ahead with a patch or a github fork. We'll have a
closer look at it.

On Sunday, September 19, 2010, Adrian Trenaman <tr...@progress.com> wrote:
> Thanks Guillaume for the quick reply on a Sunday!
>
> OK. Can I suggest that I submit the patch as is, so that we can get it into the code-base, and then we can look to fixing the issue? Many eyes may squash this bug.
>
> Let me know if you're happy for me to submit the code.
>
> Best,
> Ade.
>
> On 19/09/2010 21:29, Guillaume Nodet wrote:
>
> Not sure what the exact problem is but it does look like a bug in the
> arie blueprint implementation.
>
> On Sunday, September 19, 2010, adrian.trenaman
> <ad...@googlemail.com>  wrote:
>
>
> Hi there,
>
> Have been doing some work on my Karaf archive deployer, which is working
> nicely -except- when I shut down the Karaf instance: I see this nasty stack
> trace. I've stepped through right to the Felix code and it seems that after
> the unregister of my 'kar:' url handler service, the runtime tries to
> register it again (why?!) and then this fails because the bundle in question
> (org.apache.karaf.deployer.kar) is in a Stopping state - hence the
> 'IllegalStateException'.
>
> I'll keep banging my head against this, but I'm keen to know if anyone else
> out there has seen this or might have an idea of what I've done wrong. BTW,
> I've based all my deployer code on the existing code for the features and
> blueprints deployers.
>
> Thanks in advance,
> Ade.
>
> ---
>
> java.lang.IllegalStateException: Can only register services while bundle is
> active or activating
>          at org.apache.felix.framework.Felix.registerService(Felix.java:2817)
>          at
> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
>          at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:388)
>          at
> org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:166)
>          at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:596)
>          at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:393)
>          at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceRemoved(AbstractServiceReferenceRecipe.java:385)
>          at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:355)
>          at
> org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:864)
>          at
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:732)
>          at
> org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
>          at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3726)
>          at org.apache.felix.framework.Felix.access$000(Felix.java:80)
>          at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:717)
>          at
> org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:135)
>          at
> org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:129)
>          at
> org.apache.aries.blueprint.container.ServiceRecipe.unregister(ServiceRecipe.java:183)
>          at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.unregisterServices(BlueprintContainerImpl.java:657)
>          at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.destroy(BlueprintContainerImpl.java:806)
>          at
> org.apache.aries.blueprint.container.BlueprintExtender.destroyContext(BlueprintExtender.java:204)
>          at
> org.apache.aries.blueprint.container.BlueprintExtender.bundleChanged(BlueprintExtender.java:196)
>          at
> org.apache.aries.blueprint.container.BlueprintExtender$BlueprintBundleTrackerCustomizer.modifiedBundle(BlueprintExtender.java:385)
>          at
> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
>          at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
>          at
> org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
>          at
> org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:800)
>          at
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:728)
>          at
> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(Ev

-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Posted by Adrian Trenaman <tr...@progress.com>.
Thanks Guillaume for the quick reply on a Sunday!

OK. Can I suggest that I submit the patch as is, so that we can get it 
into the code-base, and then we can look to fixing the issue? Many eyes 
may squash this bug.

Let me know if you're happy for me to submit the code.

Best,
Ade.

On 19/09/2010 21:29, Guillaume Nodet wrote:
> Not sure what the exact problem is but it does look like a bug in the
> arie blueprint implementation.
>
> On Sunday, September 19, 2010, adrian.trenaman
> <ad...@googlemail.com>  wrote:
>    
>> Hi there,
>>
>> Have been doing some work on my Karaf archive deployer, which is working
>> nicely -except- when I shut down the Karaf instance: I see this nasty stack
>> trace. I've stepped through right to the Felix code and it seems that after
>> the unregister of my 'kar:' url handler service, the runtime tries to
>> register it again (why?!) and then this fails because the bundle in question
>> (org.apache.karaf.deployer.kar) is in a Stopping state - hence the
>> 'IllegalStateException'.
>>
>> I'll keep banging my head against this, but I'm keen to know if anyone else
>> out there has seen this or might have an idea of what I've done wrong. BTW,
>> I've based all my deployer code on the existing code for the features and
>> blueprints deployers.
>>
>> Thanks in advance,
>> Ade.
>>
>> ---
>>
>> java.lang.IllegalStateException: Can only register services while bundle is
>> active or activating
>>          at org.apache.felix.framework.Felix.registerService(Felix.java:2817)
>>          at
>> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
>>          at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:388)
>>          at
>> org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:166)
>>          at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:596)
>>          at
>> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:393)
>>          at
>> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceRemoved(AbstractServiceReferenceRecipe.java:385)
>>          at
>> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:355)
>>          at
>> org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:864)
>>          at
>> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:732)
>>          at
>> org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
>>          at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3726)
>>          at org.apache.felix.framework.Felix.access$000(Felix.java:80)
>>          at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:717)
>>          at
>> org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:135)
>>          at
>> org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:129)
>>          at
>> org.apache.aries.blueprint.container.ServiceRecipe.unregister(ServiceRecipe.java:183)
>>          at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.unregisterServices(BlueprintContainerImpl.java:657)
>>          at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.destroy(BlueprintContainerImpl.java:806)
>>          at
>> org.apache.aries.blueprint.container.BlueprintExtender.destroyContext(BlueprintExtender.java:204)
>>          at
>> org.apache.aries.blueprint.container.BlueprintExtender.bundleChanged(BlueprintExtender.java:196)
>>          at
>> org.apache.aries.blueprint.container.BlueprintExtender$BlueprintBundleTrackerCustomizer.modifiedBundle(BlueprintExtender.java:385)
>>          at
>> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
>>          at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
>>          at
>> org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
>>          at
>> org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:800)
>>          at
>> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:728)
>>          at
>> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
>>          at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3715)
>>          at org.apache.felix.framework.Felix.stopBundle(Felix.java:2180)
>>          at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1172)
>>          at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>>          at java.lang.Thread.run(Thread.java:637)
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.com/Shutting-down-Karaf-I-get-an-IllegalStateException-Can-only-register-services-while-bundle-is-active-tp1523512p1523512.html
>> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>>
>>      
>    

Re: Shutting down Karaf I get an 'IllegalStateException - Can only register services while bundle is active or activating"

Posted by Guillaume Nodet <gn...@gmail.com>.
Not sure what the exact problem is but it does look like a bug in the
arie blueprint implementation.

On Sunday, September 19, 2010, adrian.trenaman
<ad...@googlemail.com> wrote:
>
> Hi there,
>
> Have been doing some work on my Karaf archive deployer, which is working
> nicely -except- when I shut down the Karaf instance: I see this nasty stack
> trace. I've stepped through right to the Felix code and it seems that after
> the unregister of my 'kar:' url handler service, the runtime tries to
> register it again (why?!) and then this fails because the bundle in question
> (org.apache.karaf.deployer.kar) is in a Stopping state - hence the
> 'IllegalStateException'.
>
> I'll keep banging my head against this, but I'm keen to know if anyone else
> out there has seen this or might have an idea of what I've done wrong. BTW,
> I've based all my deployer code on the existing code for the features and
> blueprints deployers.
>
> Thanks in advance,
> Ade.
>
> ---
>
> java.lang.IllegalStateException: Can only register services while bundle is
> active or activating
>         at org.apache.felix.framework.Felix.registerService(Felix.java:2817)
>         at
> org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
>         at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:388)
>         at
> org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:166)
>         at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:596)
>         at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:393)
>         at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceRemoved(AbstractServiceReferenceRecipe.java:385)
>         at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:355)
>         at
> org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:864)
>         at
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:732)
>         at
> org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
>         at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3726)
>         at org.apache.felix.framework.Felix.access$000(Felix.java:80)
>         at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:717)
>         at
> org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:135)
>         at
> org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:129)
>         at
> org.apache.aries.blueprint.container.ServiceRecipe.unregister(ServiceRecipe.java:183)
>         at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.unregisterServices(BlueprintContainerImpl.java:657)
>         at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.destroy(BlueprintContainerImpl.java:806)
>         at
> org.apache.aries.blueprint.container.BlueprintExtender.destroyContext(BlueprintExtender.java:204)
>         at
> org.apache.aries.blueprint.container.BlueprintExtender.bundleChanged(BlueprintExtender.java:196)
>         at
> org.apache.aries.blueprint.container.BlueprintExtender$BlueprintBundleTrackerCustomizer.modifiedBundle(BlueprintExtender.java:385)
>         at
> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
>         at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
>         at
> org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
>         at
> org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:800)
>         at
> org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:728)
>         at
> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
>         at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3715)
>         at org.apache.felix.framework.Felix.stopBundle(Felix.java:2180)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1172)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>         at java.lang.Thread.run(Thread.java:637)
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Shutting-down-Karaf-I-get-an-IllegalStateException-Can-only-register-services-while-bundle-is-active-tp1523512p1523512.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>

-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com