title: How to deploy WAR using Netbeans 7.3.1 + JBoss AS7
body: <p>This is an existing project that builds and deploys just fine using Intellij + AS7.  I want to build and deploy using Netbeans 7.3.1 so I created a new Maven project in NetBeans, selecting the "import the project using the Maven pom.xml files" option.  NetBeans recognized the modules and used Maven to build the project successfully.  Very nice.</p>
  
  <pre><code>Webapp assembled in [931 msecs]
  Building war: G:\Patrac_Netbeans\Patrac-web\target\Patrac-web-1.0.war
  </code></pre>
  
  <p>Next, I started JBoss using NetBeans' Services panel.  Next, I clicked the Run Project button, expecting deployment to occur, but NetBeans only rebuilt the project again.  And then I remembered configuring Intellij to build &amp; deploy using the target directory.  I don't see a way to do this in NetBeans.  So, how to set up the deployment using NetBeans?  </p>
  
  <p><strong>UPDATE 8/20/2013:</strong></p>
  
  <p>The deployment of the EJB- and WAR modules work.  Here's the output when deploying the EJB:</p>
  
  <blockquote>
    <p>cd G:\Patrac_Netbeans\Patrac-ejb; "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25" "\"G:\Program Files\NetBeans 7.3.1\java\maven\bin\mvn.bat\"" -Dnetbeans.deploy=true package</p>
    
    <p>Scanning for projects...</p>
    
    <p>Building Patrac EJB module 1.0</p>
    
    <p>...</p>
    
    <p>BUILD SUCCESS</p>
    
    <p>Total time: 8.251s</p>
    
    <p>Finished at: Tue Aug 20 14:33:38 EDT 2013</p>
    
    <p>Final Memory: 22M/364M</p>
    
    <p>NetBeans: Deploying on JBoss Application Server</p>
  
  <pre><code>profile mode: false
  debug mode: false
  force redeploy: true
  </code></pre>
    
    <p>Distributing G:\Patrac_Netbeans\Patrac-ejb\target\Patrac-ejb.jar to [org.jboss.as.ee.deployment.spi.DeploymentManagerTarget@45fbf23c]</p>
    
    <p>Deploying G:\Patrac_Netbeans\Patrac-ejb\target\Patrac-ejb.jar</p>
  </blockquote>
  
  <p>However when I attempt to run the whole application NetBeans doesn't deploy:</p>
  
  <blockquote>
    <p>cd G:\Patrac_Netbeans; "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25" "\"G:\Program Files\NetBeans 7.3.1\java\maven\bin\mvn.bat\"" -Dnetbeans.deploy=true package</p>
    
    <p>Scanning for projects...</p>
    
    <p>Reactor Build Order:</p>
    
    <p>PATRAC</p>
    
    <p>Patrac EJB module</p>
    
    <p>Patrac Web module</p>
    
    <p>Building PATRAC 1.0-SNAPSHOT</p>
    
    <p>...</p>
    
    <p>Building Patrac EJB module 1.0</p>
    
    <p>...</p>
    
    <p>Building Patrac Web module 1.0</p>
    
    <p>...</p>
    
    <p>[war:war]</p>
    
    <p>Packaging webapp</p>
    
    <p>Assembling webapp [Patrac-web] in [G:\Patrac_Netbeans\Patrac-web\target\Patrac.war]</p>
    
    <p>Processing war project</p>
    
    <p>Copying webapp resources [G:\Patrac_Netbeans\Patrac-web\src\main\webapp]</p>
    
    <p>Webapp assembled in [557 msecs]</p>
    
    <p>Building war: G:\Patrac_Netbeans\Patrac-web\target\Patrac-web-1.0.war</p>
    
    <p>Reactor Summary:</p>
    
    <p>PATRAC - Physician Assistant Tracking ............. SUCCESS [0.043s]</p>
    
    <p>Patrac EJB module ................................. SUCCESS [8.100s]</p>
    
    <p>Patrac Web module ................................. SUCCESS [2.324s]</p>
    
    <p>BUILD SUCCESS</p>
    
    <p>Total time: 10.882s</p>
    
    <p>Finished at: Tue Aug 20 14:17:34 EDT 2013</p>
    
    <p>Final Memory: 25M/366M</p>
  </blockquote>
  
  <p>Why in the world does NetBeans not deploy?  Perhaps the problem is that it doesn't know where the assembled WAR is located?  Looking at the output, it runs Maven from <code>G:\Patrac_Netbeans</code>, which is where the root POM is located.  However the assembled WAR is located in <code>G:\Patrac_Netbeans\Patrac-web\target\Patrac.war</code>.</p>
  
  <p><strong>UPDATE 8/21/2013:</strong></p>
  
  <p>Fyi the plugin config was as follows:</p>
  
  <pre><code>            &lt;plugin&gt;
                  &lt;groupId&gt;org.jboss.as.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;jboss-as-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;7.4.Final&lt;/version&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>As @happymeal correctly pointed out (see his comment, below), by simply looking at Maven's output the plugin was not running.  Thanks to @James R. Perkins I realized there were actually two plugins: <code>jboss-maven-plugin</code> and <code>jboss-as-maven-plugin</code> and because I was using the latter plugin I was using the wrong goal: <code>jboss:deploy</code> instead of <code>jboss-as:deploy</code>.  Correcting this mistake and rerunning the project in Netbeans the following error occurred:</p>
  
  <pre><code>Caused by: java.io.FileNotFoundException: G:\Patrac_Netbeans\target\Patrac-1.0-SNAPSHOT.maven-project (The system cannot find the path specified)
  </code></pre>
  
  <p>Next, I added some configuration parameters that ultimately solved the problem:</p>
  
  <pre><code>            &lt;plugin&gt;
                  &lt;groupId&gt;org.jboss.as.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;jboss-as-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;7.4.Final&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;force&gt;true&lt;/force&gt;
                      &lt;targetDir&gt;G:\Patrac_Netbeans\Patrac-web\target&lt;/targetDir&gt;
                      &lt;filename&gt;Patrac-web-1.0.war&lt;/filename&gt;
                  &lt;/configuration&gt;                    
              &lt;/plugin&gt;
  </code></pre>
  
  <p>Problem solved!</p>