<div dir="ltr">Hi folks,<div><br></div><div>I am now working on a test of the Spring Boot addon setup command. I was really happy with the changes that you did in the Forge test infrastructure that allow avoiding listing all the addons that my command depends on in the @AddonDependencies annotation as well as repeating some of them in the deployment method body. I was finally able to <a href="https://github.com/forge/core/blob/master/javaee/tests/src/test/java/org/jboss/forge/addon/javaee/security/ui/AbstractSecurityCommandTest.java">write tests like that</a>:</div><div><pre style="color:rgb(0,0,0);font-family:Inconsolata"><font size="4"><span style="color:rgb(128,128,0)">@Deployment<br></span><span style="color:rgb(128,128,0)">@AddonDependencies<br></span><span style="color:rgb(0,0,128);font-weight:bold">public static </span>AddonArchive getDeployment()<br>{<br>   <span style="color:rgb(0,0,128);font-weight:bold">return </span>ShrinkWrap<br>            .<span style="font-style:italic">create</span>(AddonArchive.<span style="color:rgb(0,0,128);font-weight:bold">class</span>)<br>            .addBeansXML()<br>            .addClass(ProjectHelper.<span style="color:rgb(0,0,128);font-weight:bold">class</span>)<br>            .addClass(AbstractSecurityCommandTest.<span style="color:rgb(0,0,128);font-weight:bold">class</span>);<br>}</font><span style="font-size:16.5pt"><br></span></pre></div><div>So I tried the same thing with the <a href="https://github.com/bgjug/spring-boot-forge-addon">Spring Boot addon</a> that we started developing in our JUG. However the test failed. I have attached both the test and the whole log file. I will here just paste the exception that stands out:</div><div><br></div><div><div><font face="monospace, monospace" size="1">Caused by: java.lang.LinkageError: loader constraint violation: when resolving overridden method &quot;org.jboss.forge.addon.springboot.ui.SpringBootSetupCommand.getProjectFactory()Lorg/jboss/forge/addon/projects/ProjectFactory;&quot; the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/forge/addon/springboot/ui/SpringBootSetupCommand, and its superclass loader (instance of org/jboss/modules/ModuleClassLoader), have different Class objects for the type tupCommand.getProjectFactory()Lorg/jboss/forge/addon/projects/ProjectFactory; used in the signature</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Class.getDeclaredMethods0(Native Method)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Class.getDeclaredMethods(Class.java:1860)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Class.getEnclosingMethod(Class.java:937)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:401)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.util.Beans.isTypeManagedBeanOrDecoratorOrInterceptor(Beans.java:492)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:213)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.bootstrap.BeanDeployer.createClassBeans(BeanDeployer.java:191)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:262)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:373)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.weld.environment.se.Weld.initialize(Weld.java:134)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.forge.furnace.container.cdi.lifecycle.WeldAddonLifecycleProvider.start(WeldAddonLifecycleProvider.java:77)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.forge.furnace.impl.addons.AddonRunnable$2.call(AddonRunnable.java:92)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.forge.furnace.impl.addons.AddonRunnable$2.call(AddonRunnable.java:86)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:42)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at org.jboss.forge.furnace.impl.addons.AddonRunnable.run(AddonRunnable.java:85)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.util.concurrent.FutureTask.run(FutureTask.java:262)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)</font></div><div><font face="monospace, monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Thread.run(Thread.java:745)</font></div></div><div><br></div><div>What I see different between the spring boot addon and the java ee addon, where the referenced test belongs to, is that our addon has its pom.xml dependencies in <i>provided</i> scope. </div><div><br></div><div>Is that the possible cause? Would you please give us advise how to write tests outside the core addons?</div><div><br></div><div>Thanks and regards,</div><div>Ivan</div></div>