<HTML><BODY>Hi all,<br><br>I am posting the result of solution to make Weld work as JPMS auto module.<br><br>In this solution I use only module path. I manually create JPMS layer and add all modules<br>to it. For Weld I added the following modules:<br><br>&nbsp;&nbsp;&nbsp; &lt;module file="cdi-api-2.0.jar"/&gt;<br>&nbsp;&nbsp; &nbsp;&lt;module file="javax.annotation-api-1.3.2.jar"/&gt;<br>&nbsp;&nbsp; &nbsp;&lt;module file="javax.inject-1.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="javax.interceptor-api-1.2.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="jboss-classfilewriter-1.2.2.Final.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="jboss-logging-3.2.1.Final.jar"/&gt;<br>&nbsp;&nbsp; &nbsp;&lt;module file="guava-18.0.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="weld-se-core-3.0.4.Final.jar"/&gt;<br>&nbsp;&nbsp; &nbsp;&lt;module file="weld-environment-common-3.0.4.Final.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="weld-core-impl-3.0.4.Final.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="weld-spi-3.0.SP3.jar"/&gt;<br>&nbsp;&nbsp; &nbsp;&lt;module file="weld-api-3.0.SP3.jar"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;module file="jandex-2.0.5.Final.jar"/&gt;<br><br>Note, that jandex is 2.0.5 but not 2.0.3 as 2.0.3 doesn't work well with java9. Besides Weld modules<br>I have two modules - in beanModule( here I have my cdi beans + beans.xml) and serverModule (here<br>I create Weld etc).<br><br>In serverModule I have the following code:<br><br>Weld builder = new Weld()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .property("org.jboss.weld.construction.relaxed", true)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .setClassLoader(this.getClass().getClassLoader())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .setResourceLoader(new ResourceLoaderImpl());<br>WeldContainer container = builder.initialize();<br>BeanManager bm = container.getBeanManager();<br><br>This is my ResourceLoaderImpl:<br><br>public class ResourceLoaderImpl implements ResourceLoader {<br><br>&nbsp;&nbsp;&nbsp; private static final String ERROR_LOADING_CLASS = "Error loading class ";<br><br>&nbsp;&nbsp;&nbsp; @Override<br>&nbsp;&nbsp;&nbsp; public Class&lt;?&gt; classForName(String name) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Class.forName(name);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (ClassNotFoundException e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new ResourceLoadingException(ERROR_LOADING_CLASS + name, e);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (LinkageError e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new ResourceLoadingException(ERROR_LOADING_CLASS + name, e);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (TypeNotPresentException e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new ResourceLoadingException(ERROR_LOADING_CLASS + name, e);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; @Override<br>&nbsp;&nbsp;&nbsp; public URL getResource(String name) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Module module = this.getClass().getModule().getLayer().findModule("beanModule").orElse(null);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ModuleReference reference = getReference(module);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Optional&lt;URI&gt; uri = reference.open().find(name);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (uri.isPresent()) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return uri.get().toURL();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (MalformedURLException ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ex.printStackTrace();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (IOException ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ex.printStackTrace();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; @Override<br>&nbsp;&nbsp;&nbsp; public Collection&lt;URL&gt; getResources(String name) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;URL&gt; result = new ArrayList&lt;&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //HERE WE NEED MODULE ITERATION<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URL url = this.getResource(name);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (url != null) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.add(url);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return result;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; @Override<br>&nbsp;&nbsp;&nbsp; public void cleanup() {&nbsp; }<br>}<br><br>In beanModule in module-info I open packages, that contains beans.<br><br>The solution WORKS, via BeanManager I can get whatever bean I need. The only problem is that I can't<br>understand what I should return in getResouce(String) if I have many modules - what module first I should<br>return? For example, when weld calls getResource("META-INF/beans.xml") - ?<br><br>It would be very interesting to to get some comments.<br>-- <br>Best regards, Alex<br></BODY></HTML>