title: How to build an EAR project with EJB and WAR using Maven?
body: <p>I tried to create EAR Project with EJB and WAR but I have some problem.
  I created the main project from the <a href="https://mvnrepository.com/artifact/org.codehaus.mojo.archetypes/ear-javaee6" rel="nofollow noreferrer">Java EE 6 EAR Archetype</a>:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.codehaus.mojo.archetypes&lt;/groupId&gt;
      &lt;artifactId&gt;ear-javaee6&lt;/artifactId&gt;
      &lt;version&gt;1.5&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Then I created the EJB module from the <a href="https://mvnrepository.com/artifact/org.codehaus.mojo.archetypes/ejb-javaee6" rel="nofollow noreferrer">Java EE 6 EJB JAR Archetype</a>:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.codehaus.mojo.archetypes&lt;/groupId&gt;
      &lt;artifactId&gt;ejb-javaee6&lt;/artifactId&gt;
      &lt;version&gt;1.5&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>And then I created the second module from the <a href="https://mvnrepository.com/artifact/javax.faces/javax.faces-war-archetype" rel="nofollow noreferrer">Javax Faces WAR Archetype</a>:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;javax.faces&lt;/groupId&gt;
      &lt;artifactId&gt;javax.faces-war-archetype&lt;/artifactId&gt;
      &lt;version&gt;2.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Then I added dependencies to main pom.xml:</p>
  
  <pre><code>&lt;!-- Define the versions of your ear components here --&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;QCforCC-main&lt;/groupId&gt;
          &lt;artifactId&gt;QCforCC-ejb&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;type&gt;ejb&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;QCforCC-main&lt;/groupId&gt;
          &lt;artifactId&gt;QCforCC-war&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;type&gt;war&lt;/type&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>And then I tried to build the project - using maven clean and instal .
  But I have an error:</p>
  
  <pre><code>  [ERROR] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='QCforCC-main:QCforCC-war:1.0-SNAPSHOT'}' and 'Vertex{label='QCforCC-main:QCforCC-ejb:1.0-SNAPSHOT'}' introduces to cycle in the graph QCforCC-main:QCforCC-ejb:1.0-SNAPSHOT --&gt; QCforCC-main:QCforCC-war:1.0-SNAPSHOT --&gt; QCforCC-main:QCforCC-ejb:1.0-SNAPSHOT -      [Help 1] 
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging. 
    [ERROR]  
    [ERROR] For more information about the errors and possible solutions, please read the following articles: 
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectCycleException
  
    Process finished with exit code 1
  </code></pre>
  
  <p>And in EAR <code>pom.xml</code> I have:</p>
  
  <pre><code>&lt;modules&gt;
      &lt;module&gt;QCforCC-ejb&lt;/module&gt;
      &lt;module&gt;QCforCC-war&lt;/module&gt;
  &lt;/modules&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  </code></pre>
  
  <p>But if I change <code>&lt;packaging&gt;pom&lt;/packaging&gt;</code> to <code>&lt;packaging&gt;ear&lt;/packaging&gt;</code>
  IDEA show error in popup:</p>
  
  <pre><code>  Some problems were encountered while processing the POMs: 
    [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-ear-plugin @ line 41, column 21 
    [ERROR]   'packaging' with value 'ear' is invalid. Aggregator projects require 'pom' as packaging. @ line 12, column 16
  </code></pre>