Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I configure a maven web application to auto-deploy on glassfish when I "mvn install" from command line?
    primarykey
    data
    text
    <p>I'm working with the javaee tutorials with glassfish and maven. I can get the example to run fine. What I'm trying to do is recreate the same example from scratch which I have done. (created by opening a new maven project in netbenas</p> <p>With the examples though, from command line when I <code>mvn install</code> the example app automatically gets deployed on the glassfish server. I'm thinking the reason fort his is that the example file is already placed in the glassfish directory</p> <pre><code>C:\ glassfish4 docs javaee-tutorial examples web jsf hello1 (target application) </code></pre> <p>Now my project is being created in a different NetBeansProjects directory</p> <pre><code>C:\ netbeansprojects javaee_tuts practiceproject (target application) </code></pre> <p>The <code>example</code> project gets automatically deployed, but my <code>practiceproject</code> doesn't get deployed. I'm guessing because the project is not in the glassfish directory or it could a combination of this and other things, of which I'm not sure. I thought maybe I could configure it somehow with the <code>pom.xml</code> but I'm very new to maven, and not too familiar with the <code>pom</code>.</p> <p>Here are the two <code>pom</code>s</p> <p>example <code>pom</code></p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;parent&gt; &lt;artifactId&gt;jsf&lt;/artifactId&gt; &lt;groupId&gt;org.glassfish.javaeetutorial&lt;/groupId&gt; &lt;version&gt;7.0.3&lt;/version&gt; &lt;/parent&gt; &lt;groupId&gt;org.glassfish.javaeetutorial&lt;/groupId&gt; &lt;artifactId&gt;hello1&lt;/artifactId&gt; &lt;version&gt;7.0.3&lt;/version&gt; &lt;packaging&gt;war&lt;/packaging&gt; &lt;name&gt;${project.artifactId}&lt;/name&gt; &lt;/project&gt; </code></pre> <p>My practiceproject pom</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.mavenpractice&lt;/groupId&gt; &lt;artifactId&gt;practiceproject&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;war&lt;/packaging&gt; &lt;name&gt;practiceproject&lt;/name&gt; &lt;properties&gt; &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;javax&lt;/groupId&gt; &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt; &lt;version&gt;7.0&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.1&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;1.7&lt;/source&gt; &lt;target&gt;1.7&lt;/target&gt; &lt;compilerArguments&gt; &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt; &lt;/compilerArguments&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;version&gt;2.3&lt;/version&gt; &lt;configuration&gt; &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;version&gt;2.6&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;phase&gt;validate&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;copy&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt; &lt;silent&gt;true&lt;/silent&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;javax&lt;/groupId&gt; &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt; &lt;version&gt;7.0&lt;/version&gt; &lt;type&gt;jar&lt;/type&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>I can get the project to deploy through netbeans, that's no problem, but I want to practice using maven through command line. So to conclude with a single question:</p> <blockquote> <p><b>What do I need to do to get my practice project to auto deploy on glassfish using <code>mvn install</code> from command line?</b></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThe default `mvn install` doesn't automatically deploy your project to glassfish server. It just installs your built project into its own maven cache (commonly found here: ${MAVEN_HOME}/repository). You need some external maven plugins to work with this: See [this question](http://stackoverflow.com/q/9964922/205936) and [this SO answer](http://stackoverflow.com/a/12752063/205936) - customise accordingly. You can find the maven glassfish plugin [here](https://maven-glassfish-plugin.java.net/)
      singulars
    2. CO@S.R.I. Then why does the example app get deployed to the server. Is it because It is in the glassfish directory? That is my question. If I'm using `mvn install` for the example and the example gets deployed, what can I do to replicate this action? Should I place the `practiceproject` in the glassfish directory also?
      singulars
    3. COThat's because Netbeans already has a connector configured in its pom.xml (or `build.xml` if it's ant based deploy) to deploy into glassfish. That's the reason why you could deploy easily through an IDE. But while running/deploying from command line, you have to rely on maven plugins to do the task for you.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload