How did you obtain an instance of Service1 in your example below? If you
create it using new Service1(), then injection manager can't get a
chance to inject. I suspect that's what is happening for you. You should
really use @Inject in objects which are created for you by container.
Sahoo
On Saturday 24 December 2011 08:02 PM, forums_at_java.net wrote:
> Hi,
>
> I'm using osgi-cdi to inject osgi services and it looks like injecting
> osgi
> service inside another injected osgi service doesn't work.
> I have the following code:
> [code]
> public class Hello {
> @Inject @OSGiService(dynamic=true)
> private Service1 service1;
> public void useService1() {
> service1.useService2();
> }
> }
> public class Service1 {
> @Inject @OSGiService(dynamic=true)
> private Service2 service2; // NULL, service is not injected, although it
> exists
> public void useService2() {
> service2.doSomething(); // NPE
> }
> }
> [/code]
> The problem is that service2 is always null. So it looks ike nested
> injections of OSGI services doesn't work.
> I'm using GF 3.1.
> Is it a bug? Am I
> Thanks.
>
>
>
> --
>
> [Message sent by forum member 'Karo']
>
> View Post: http://forums.java.net/node/877196
>
>