title: How do I tell Wildfly that I want to use the Wildfly module when deploying an EAR?
body: <p>I'm using Wildfly 11 with Java 8.  Previously I was building a WAR file, which required the dom4j JAR file.  Rather than including it in the WAR's WEB-INF/lib directory, I linked to the Wildfly modules JAR by adding an entry in the WEB-INF/jboss-deployment-structure.xml.  Now I want to package this WAR as part of an EAR.  So I created a jboss-deploymebnt-structure.xml file at teh root of the EAR, with these lines</p>
  
  <pre><code>&lt;jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"&gt;
          &lt;deployment&gt;
                  &lt;sub-deployment name="myapp.war"&gt;
                          &lt;dependencies&gt;
                          ...
                                  &lt;module name="org.dom4j" /&gt;
  </code></pre>
  
  <p>Now when I deploy the EAR, the WAR is failing to deploy with errors like</p>
  
  <pre><code>  service jboss.undertow.deployment.default-server.default-host./myapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./orgsclient: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/spring/infrastructure.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/dom4j/io/STAXEventReader
  </code></pre>
  
  <p>What else do I need to do to tell the EAR file that the WAR is using the Wildly module dom4j as opposed to one I'm packaging with the EAR itself?</p>