You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Anthony Bargnesi (JIRA)" <ji...@apache.org> on 2012/10/17 14:24:03 UTC
[jira] [Commented] (FELIX-3576) iPOJO fails when using constructor
injection and expecting BundleContext in ctor
[ https://issues.apache.org/jira/browse/FELIX-3576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13477812#comment-13477812 ]
Anthony Bargnesi commented on FELIX-3576:
-----------------------------------------
A similar issue is still occurring. If I define a component with a constructor that takes another required component and a BundleContext then I receive the following stacktrace:
{code:title=Bar.java|borderStyle=solid}
[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:
{code}
An example component definition that reveals this issue is:
{code:title=Bar.java|borderStyle=solid}
@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;
}
}
{code}
> iPOJO fails when using constructor injection and expecting BundleContext in ctor
> --------------------------------------------------------------------------------
>
> Key: FELIX-3576
> URL: https://issues.apache.org/jira/browse/FELIX-3576
> Project: Felix
> Issue Type: Bug
> Components: iPOJO
> Affects Versions: ipojo-core-1.8.2
> Reporter: Daan de Wit
> Assignee: Göktürk Gezer
> Fix For: ipojo-core-1.8.4
>
>
> When using constructor inject, and also expecting BundleContext to be passed into the constructor, iPOJO gives and error: The constructor parameter 0 is not managed
> The constructor is defined as something like this:
> public Constructor(BundleContext context, @Requires(id="my-id") Dependency1 dep) { /* ... */ }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira