Patrick Garner
Patrick Garner

Reputation: 3321

How to deploy WAR using Netbeans 7.3.1 + JBoss AS7

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.

Webapp assembled in [931 msecs]
Building war: G:\Patrac_Netbeans\Patrac-web\target\Patrac-web-1.0.war

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 & 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?

UPDATE 8/20/2013:

The deployment of the EJB- and WAR modules work. Here's the output when deploying the EJB:

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

Scanning for projects...

Building Patrac EJB module 1.0

...

BUILD SUCCESS

Total time: 8.251s

Finished at: Tue Aug 20 14:33:38 EDT 2013

Final Memory: 22M/364M

NetBeans: Deploying on JBoss Application Server

profile mode: false
debug mode: false
force redeploy: true

Distributing G:\Patrac_Netbeans\Patrac-ejb\target\Patrac-ejb.jar to [org.jboss.as.ee.deployment.spi.DeploymentManagerTarget@45fbf23c]

Deploying G:\Patrac_Netbeans\Patrac-ejb\target\Patrac-ejb.jar

However when I attempt to run the whole application NetBeans doesn't deploy:

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

Scanning for projects...

Reactor Build Order:

PATRAC

Patrac EJB module

Patrac Web module

Building PATRAC 1.0-SNAPSHOT

...

Building Patrac EJB module 1.0

...

Building Patrac Web module 1.0

...

[war:war]

Packaging webapp

Assembling webapp [Patrac-web] in [G:\Patrac_Netbeans\Patrac-web\target\Patrac.war]

Processing war project

Copying webapp resources [G:\Patrac_Netbeans\Patrac-web\src\main\webapp]

Webapp assembled in [557 msecs]

Building war: G:\Patrac_Netbeans\Patrac-web\target\Patrac-web-1.0.war

Reactor Summary:

PATRAC - Physician Assistant Tracking ............. SUCCESS [0.043s]

Patrac EJB module ................................. SUCCESS [8.100s]

Patrac Web module ................................. SUCCESS [2.324s]

BUILD SUCCESS

Total time: 10.882s

Finished at: Tue Aug 20 14:17:34 EDT 2013

Final Memory: 25M/366M

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 G:\Patrac_Netbeans, which is where the root POM is located. However the assembled WAR is located in G:\Patrac_Netbeans\Patrac-web\target\Patrac.war.

UPDATE 8/21/2013:

Fyi the plugin config was as follows:

            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.4.Final</version>
            </plugin>

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: jboss-maven-plugin and jboss-as-maven-plugin and because I was using the latter plugin I was using the wrong goal: jboss:deploy instead of jboss-as:deploy. Correcting this mistake and rerunning the project in Netbeans the following error occurred:

Caused by: java.io.FileNotFoundException: G:\Patrac_Netbeans\target\Patrac-1.0-SNAPSHOT.maven-project (The system cannot find the path specified)

Next, I added some configuration parameters that ultimately solved the problem:

            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.4.Final</version>
                <configuration>
                    <force>true</force>
                    <targetDir>G:\Patrac_Netbeans\Patrac-web\target</targetDir>
                    <filename>Patrac-web-1.0.war</filename>
                </configuration>                    
            </plugin>

Problem solved!

Upvotes: 3

Views: 7096

Answers (1)

happymeal
happymeal

Reputation: 1413

the default maven goal for the "Run Project" button in netbeans is package. this goal builds the project but does not deploy your app.

you can change this by:

  1. right-clicking on your project and go to properties.
  2. under the categories panel, select actions.
  3. select the "Run Project" action and edit the "Execute Goals" textbox (e.g. jboss:start).

note that you will need the jboss maven plugin.

Upvotes: 3

Related Questions