jarcdiweld-se

weld-se unable to find bean in different jar on classpath when running from command line


I've got a simple standalone application that uses weld-se, but I fail to get beans detected from all bean archives on my classpath

Basically, I have a bunch of jar files in the directory where I run:

java -classpath * a.b.c.Generator

Two of these jar files are bean archives, and the beans contained in the jar where the weld.initialize() happens are nicely discovered.

However, those from other jar files are completely ignored. This seems strange to me, though I am not wondering if this actually how it was intended. And if so, what would be a different solution?


Solution

  • In my case, I have been unable to make Weld discover the beans in the other jars on my classpath, when running via the commandline like mentioned.

    The beanmanager that gets registered discovers only the beans with the jar file where Weld is initialized. Logging indicates this, noting "Bean manager for "/jar/C:/....", so just for one jar file.

    To work around this, I have combined all jar files from which I need the beans discovered (with an empty META-INF/beans.xml), and then ran my application like above.