[forge-dev] Problem with beanManager.getReference(InjectionPoint, CreationalContext)

Lincoln Baxter, III lincolnbaxter at gmail.com
Fri Jan 11 17:27:15 EST 2013


Hey all,

I have a problem with "Faking an injection point," with the current Weld 2
code, seems to be throwing an NPE instead of using the InjectionPoint that
I am providing the BeanManager with.

This can be reproduced right now by checking out the forge core repository
branch 2.0. Just run, mvn clean install.

https://github.com/forge/core/tree/2.0

The crux of the matter, we have a producer method in a CDI instance A:

@Produces
public static Coverter<?,?> produceRemoteConverter(AddonRegistry registry,
InjectionPoint ip)

There are, however, no injection points actually consuming this
type/producer method from within CDI instance A. (And adding one would not
really help.)

In CDI instance, B, however, we are using the following code, with a
reference to the BeanManager from CDI instance A, to get an instance of a
Converter:

Bean<R> bean = (Bean<R>) manager.resolve(manager.getBeans(type));
context = manager.createCreationalContext(bean);
Object delegate = manager.getInjectableReference(injectionPoint, context);

We have an InjectionPoint for the Converter type in CDI instance B, and are
delegating to container A to get the instance (using an extension.)

However, even though we are passing in our own InjectionPoint(B) into CDI
instance A, CDI instance A still tries to look up the InjectionPoint on its
internal stack, and throws a NullpointerException.

I think this is a bug, since InjectionPoint is an interface, (but obviously
very edge case if so.)

Any help would be appreciated. Otherwise, we have no way to support looking
up beans for types which are produced with Producer Methods requiring an
injection point (those without work fine, and normal type lookups obviously
work fine.)

-- 
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20130111/aa03934d/attachment.html 


More information about the forge-dev mailing list