Jens,

For your first bullet, I believe this is reflected in the CDI 1.1 spec now
(what you can and cannot inject into an extension).

John


On Fri, Mar 22, 2013 at 6:41 PM, Jens Schumann <
[email protected]> wrote:

>  Hi all!
>
>  I tried to upgrade an old project from OWB 1.1.3 to 1.1.7 – which
> obviously failed (since I would not send this e-mail otherwise;). It turned
> out that I had an extension that checks during AfterBeanDiscovery whether a
> certain bean exists or not. If the bean (UserTransaction) does not exists
> the extension registers a new bean of this type.
>
>  With 1.1.3 it worked perfectly, everything above 1.1.4 failed with an
> missing UserTransaction dependency in the validate phase. My debugger
> showed a valid UserTransaction bean in my BeanManager instance,
> however InjectionResolver#checkInjectionPoints could not resolve my
> dependency. My extension basically did the following:
>
>    public void addLinkToResource(@Observes AfterBeanDiscovery event,
> BeanManager bm) {
>      Set<Bean<?>> set = bm.getBeans(UserTransaction.class);
>     if (set.size() == 0) {
>       // register new UserTransaction
>       event.addBean(…)
>     }
>  }
>
>  From what I understood the above code enforces an empty set of
> resolvedComponents in InjectionResolver#implResolveByType, since my
> getBeans() call will register an empty set for the
> cached UserTransaction BeanCacheKey. Event.addBean() does not update the
> cache though.
>
>  While talking to Arne today it seems that
>
>    - we definitely should prohibit a call to getBeans() within an
>    extension – a CDI spec topic I know. I switched to ProcessBean,
>    ProcessProducerMethod, ProcessProducerField for UserTransaction detection
>    and everything works with 1.1.7.
>    - You guys should check wether addBean should clear cached values
>    within OWB in order to avoid the issue above.
>
> I you think this is a bug in OWB I can create a JIRA ticket.
> Jens
>
>

Reply via email to