ops4j / org.ops4j.pax.cdi

Contexts and Dependency Injection for OSGi
Apache License 2.0
34 stars 26 forks source link

Cannot register beans created by producer methods as OSGi services #34

Open mwinkels opened 8 years ago

mwinkels commented 8 years ago

When the @OsgiServiceProvider annotation is used on a producer method (which should be possible according to its JavaDoc) the following exception is thrown:

15:19:10.895 [Start Level Event Dispatcher] INFO  o.o.p.c.e.i.c.ComponentLifecycleManager - component Greeter, Name:null, WebBeans Type:PRODUCERMETHOD, API Types:[java.lang.Object,sample.osgiProviderProducerMethod.Greeter], Qualifiers:[javax.enterprise.inject.Any,org.ops4j.pax.cdi.api.OsgiServiceProvider] is available
15:19:10.912 [Start Level Event Dispatcher] ERROR o.o.pax.cdi.spi.AbstractCdiContainer - 
java.lang.NullPointerException: null
    at org.ops4j.pax.cdi.extension.impl.component.ComponentLifecycleManager.registerService(ComponentLifecycleManager.java:183) ~[pax-cdi-extension-0.13.0-SNAPSHOT.jar:na]
    at org.ops4j.pax.cdi.extension.impl.component.ComponentLifecycleManager.start(ComponentLifecycleManager.java:107) ~[pax-cdi-extension-0.13.0-SNAPSHOT.jar:na]
    at org.ops4j.pax.cdi.extension.impl.component.ComponentLifecycleManager$$OwbNormalScopeProxy0.start(org/ops4j/pax/cdi/extension/impl/component/ComponentLifecycleManager.java) ~[na:na]
    at org.ops4j.pax.cdi.extension.impl.BeanBundleImpl.onInitialized(BeanBundleImpl.java:60) ~[pax-cdi-extension-0.13.0-SNAPSHOT.jar:na]
    ...

The integration test in this pull requests show the problem. The last commit proposes a fix.

ANierbeck commented 7 years ago

thanks for providing a fix including a test :-) could you also open an issue for this at the ops4j jira and link it with this PR, this way it's documented in the next release notes.

thanks, Achim

mwinkels commented 7 years ago

Unfortunately I cannot create an account to create an issue on ops4j jira.

ANierbeck commented 7 years ago

ahh ... that's right. Let me create one for you. We unfortunately have been swamped by spam on our Jira.

Tcharl commented 7 years ago

@mwinkels did you have your JIRA account? This is a really nice addition!

jbonofre commented 4 years ago

@mwinkels I know it's pretty old. I think it has been addressed, but can you please double check and eventually update the PR based on master ?