[cdi-dev] Bean discovery question

Laird Nelson ljnelson at gmail.com
Mon Mar 20 15:47:42 EDT 2017

On Mon, Mar 20, 2017 at 10:56 AM John Ament <john.ament at spartasystems.com>

> For me, that still doesn't discover.  The only thing I can think of is
> that the JAR that includes StringSearchModelInterpolator may have a
> beans.xml (does it?)

I spoke with John off-list; wanted to shed more light on my setup.

I pushed a shaky incomplete version of what I'm doing here:

The purpose of this frightening :-) extension is uninteresting for the
subject under discussion here.  Briefly, it does just enough Plexus
annotation processing to be mildly dangerous and break things in cool ways,
and no more.

The test method is here:

Note in particular the main method is not in this project.  It is in this
one, which is a test-scoped dependency:

That project's META-INF/beans.xml has bean discovery set to none (
since there are no beans in that bean archive (it houses only the main
class).  John indicated that this was likely the source of the problem:

"Ok, knowing that this is the setup helps out dramatically.  If I had to
guess, the case of having the beans.xml from the main set to none is what's
causing this.  I remember Martin mentioned some issues with SE originally
when I pushing [*sic*] that by default we should do discovery.  My guess is
that Weld is seeing the beans.xml from the root component [microbean-main]
and actually falling back to the CDI 1.0 discovery behavior."

This project's META-INF/beans.xml has bean discovery of "annotated" (
though I confess that's mostly because I just wanted to use the default
behavior, not because I carefully considered whether that was something I
should use here or not.  In any event, I don't anticipate there being any
classes in this project with bean-defining annotations on them, nor any
other classes that I would want discovered automatically.

Perhaps I have misunderstood bean discovery: I thought that the discovery
mode applied to the bean archive in question alone, not to an aggregate.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20170320/f3f8e056/attachment.html 

More information about the cdi-dev mailing list