Hi folks,
I have an iPOJO service component that takes two constructor parameters:
- BundleContext
- another service with @Requires
My scenario is similar to the following contrived example:
@Component
@Provides
@Instantiate
public class DefaultUserService implements UserService {
...
}
@Component
@Provides
@Instantiate
public class DefaultPersonService extends ObjectService implements
PersonService {
private final BundleContext ctx;
public DefaultPersonService(BundleContext ctx,
@Requires(nullable = false, proxy = false)
UserService userService) {
super(userService);
this.ctx = ctx;
}
}
In my example I require ObjectService to be instantiated with the
UserService so it must
be a constructor parameter.
I found that if I also want BundleContext to be injected then I receive the
following
NullPointerException:
[2012-10-16 16:11:11.886] ERROR iLogServiceListener@65284069
org.osgi.service.log.LogService
Bundle person.impl_0.1.0, [ERROR] person.impl.DefaultPersonService : null
java.lang.NullPointerException: null
at
org.apache.felix.ipojo.InstanceManager.handleBCInjections(InstanceManager.java:
253)
at
org.apache.felix.ipojo.InstanceManager.configure(InstanceManager.java:207)
at
org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:
178)
at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:
310)
at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:
239)
at
org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCreator.java:
355)
at
org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89)
at org.apache.felix.ipojo.Extender.parse(Extender.java:306)
at
org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:237)
at org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
at org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:
769)
at java.lang.Thread.run(Thread.java:722)
If I remove the BundleContext constructor parameter then the UserService is
injected and the DefaultPersonService
is valid.
I have tested this against the latest trunk code at:
https://svn.apache.org/repos/asf/felix/trunk/ipojo/
I thought it could be related to the following fix:
https://issues.apache.org/jira/browse/FELIX-3576
Could this be a bug?
Thanks!
Anthony Bargnesi