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