users@glassfish.java.net

Injecting using osgi-cdi @OSGiService doesn't work with nested injections

From: <forums_at_java.net>
Date: Sat, 24 Dec 2011 08:32:30 -0600 (CST)

 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