You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com> on 2013/06/06 15:58:07 UTC

blueprintBundleContext => Invalid BundleContext

Dear Karaf Team,

I inject the BundleContext using the Blueprint reference ref="blueprintBundleContext". When I try to register a service to this context, I get the following exception:
            java.lang.IllegalStateException: Invalid BundleContext.

As it was injected, how can it be invalid?

Cheers,
JP

[@@ OPEN @@]

De : Guillaume Nodet [mailto:gnodet@apache.org]
Envoyé : mercredi 5 juin 2013 12:57
À : user
Objet : Re: service / reference-list within same bundle

Exactly, the container simply check the existence.

2013/6/5 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Good.

What is the main difference between injecting directly the string, or injecting an idref, just reference check ref existence before injection ?

JP

[@@ THALES GROUP INTERNAL @@]

De : Guillaume Nodet [mailto:gnodet@apache.org<ma...@apache.org>]
Envoyé : mercredi 5 juin 2013 12:41

À : user
Objet : Re: service / reference-list within same bundle

Yes

2013/6/5 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Ok, good.

Which kind of Java parameter type is injected for id-ref ? String?

JP

[@@ OPEN @@]

De : Guillaume Nodet [mailto:gnodet@apache.org<ma...@apache.org>]
Envoyé : mercredi 5 juin 2013 11:42

À : user
Objet : Re: service / reference-list within same bundle

You can't inject a bean manager, but you can inject the id using id-ref="xyz", inject the blueprint container using ref="blueprintContainer" and then programmatically ask the blueprint container for beans (or eventually for the metadata).  That's how you can leverage prototypes programmatically.

2013/6/5 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Guillaume,

Is there a way to inject a bean manager instead of a bean itself using Blueprint?

Cheers,
JP

[@@ OPEN @@]

De : Guillaume Nodet [mailto:gnodet@apache.org<ma...@apache.org>]
Envoyé : mardi 4 juin 2013 17:20
À : user

Objet : Re: service / reference-list within same bundle

If you don't need to iterator through osgi services, you could use a simple <list> element instead.
The problem with using osgi services and references is that if the reference is mandatory, the blueprint context won't be started until the reference is satisfied, which can't happen since the the service will be provided by the bundle itself.  However, it should work when using an optional availability instead.

2013/6/4 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Yes, you are right, not exactly meant for but it is useful :)

In fact I just wish to iterate through beans and call a method for each bean. What is strange is that it is possible among bundles but not within bundle :S

JP

[@@ OPEN @@]

De : Achim Nierbeck [mailto:bcanhome@googlemail.com<ma...@googlemail.com>]
Envoyé : mardi 4 juin 2013 16:37

À : user@karaf.apache.org<ma...@karaf.apache.org>
Objet : Re: service / reference-list within same bundle

It's not what it's meant for, reference-list is supposed to give you all available services of a interface.
Not exactly a for each, or?

regards, Achim

2013/6/4 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
In fact I would like to use the reference-list as a kind of "for each". I don't know how to do the same thing using the bean.

Is there a syntax to do so?

Cheers,
JP

[@@ OPEN @@]

De : Achim Nierbeck [mailto:bcanhome@googlemail.com<ma...@googlemail.com>]
Envoyé : mardi 4 juin 2013 16:31
À : user@karaf.apache.org<ma...@karaf.apache.org>
Objet : Re: service / reference-list within same bundle

Since you're referencing a bean from within the same bundle, it's probably best to reference the bean and not the service of it.
If you really want to use the service (which I don't understand why) you should configure Karaf to start the bundles in a synchronous way.

regards, Achim

2013/6/4 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Dear Karaf team,

I would like to use a reference-list on a service which is exported in the same bundle. Starting the bundle blocks on the GracePeriod state.

Is there a way to use a service which is exposed within the same bundle?

Cheers,
JP

[@@ OPEN @@]




--

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>



--

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>





RE: blueprintBundleContext => Invalid BundleContext

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
Well, I tried several things and found that first injected BundleContext (via ref="blueprintBundleContext") works, but then all restart injects a context which does not work and gives an Invalid BundleContext exception.

I can't explain why it works only first - help!

JP

[@@ OPEN @@]

De : CLEMENT Jean-Philippe [mailto:jean-philippe.clement@fr.thalesgroup.com]
Envoyé : jeudi 6 juin 2013 15:58
À : user@karaf.apache.org
Objet : blueprintBundleContext => Invalid BundleContext

Dear Karaf Team,

I inject the BundleContext using the Blueprint reference ref="blueprintBundleContext". When I try to register a service to this context, I get the following exception:
            java.lang.IllegalStateException: Invalid BundleContext.

As it was injected, how can it be invalid?

Cheers,
JP

[@@ OPEN @@]

De : Guillaume Nodet [mailto:gnodet@apache.org]<mailto:[mailto:gnodet@apache.org]>
Envoyé : mercredi 5 juin 2013 12:57
À : user
Objet : Re: service / reference-list within same bundle

Exactly, the container simply check the existence.

2013/6/5 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Good.

What is the main difference between injecting directly the string, or injecting an idref, just reference check ref existence before injection ?

JP

[@@ THALES GROUP INTERNAL @@]

De : Guillaume Nodet [mailto:gnodet@apache.org<ma...@apache.org>]
Envoyé : mercredi 5 juin 2013 12:41

À : user
Objet : Re: service / reference-list within same bundle

Yes

2013/6/5 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Ok, good.

Which kind of Java parameter type is injected for id-ref ? String?

JP

[@@ OPEN @@]

De : Guillaume Nodet [mailto:gnodet@apache.org<ma...@apache.org>]
Envoyé : mercredi 5 juin 2013 11:42

À : user
Objet : Re: service / reference-list within same bundle

You can't inject a bean manager, but you can inject the id using id-ref="xyz", inject the blueprint container using ref="blueprintContainer" and then programmatically ask the blueprint container for beans (or eventually for the metadata).  That's how you can leverage prototypes programmatically.

2013/6/5 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Guillaume,

Is there a way to inject a bean manager instead of a bean itself using Blueprint?

Cheers,
JP

[@@ OPEN @@]

De : Guillaume Nodet [mailto:gnodet@apache.org<ma...@apache.org>]
Envoyé : mardi 4 juin 2013 17:20
À : user

Objet : Re: service / reference-list within same bundle

If you don't need to iterator through osgi services, you could use a simple <list> element instead.
The problem with using osgi services and references is that if the reference is mandatory, the blueprint context won't be started until the reference is satisfied, which can't happen since the the service will be provided by the bundle itself.  However, it should work when using an optional availability instead.

2013/6/4 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Yes, you are right, not exactly meant for but it is useful :)

In fact I just wish to iterate through beans and call a method for each bean. What is strange is that it is possible among bundles but not within bundle :S

JP

[@@ OPEN @@]

De : Achim Nierbeck [mailto:bcanhome@googlemail.com<ma...@googlemail.com>]
Envoyé : mardi 4 juin 2013 16:37

À : user@karaf.apache.org<ma...@karaf.apache.org>
Objet : Re: service / reference-list within same bundle

It's not what it's meant for, reference-list is supposed to give you all available services of a interface.
Not exactly a for each, or?

regards, Achim

2013/6/4 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
In fact I would like to use the reference-list as a kind of "for each". I don't know how to do the same thing using the bean.

Is there a syntax to do so?

Cheers,
JP

[@@ OPEN @@]

De : Achim Nierbeck [mailto:bcanhome@googlemail.com<ma...@googlemail.com>]
Envoyé : mardi 4 juin 2013 16:31
À : user@karaf.apache.org<ma...@karaf.apache.org>
Objet : Re: service / reference-list within same bundle

Since you're referencing a bean from within the same bundle, it's probably best to reference the bean and not the service of it.
If you really want to use the service (which I don't understand why) you should configure Karaf to start the bundles in a synchronous way.

regards, Achim

2013/6/4 CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>>
Dear Karaf team,

I would like to use a reference-list on a service which is exported in the same bundle. Starting the bundle blocks on the GracePeriod state.

Is there a way to use a service which is exposed within the same bundle?

Cheers,
JP

[@@ OPEN @@]




--

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>



--

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>