Maven Embedded Glassfish plugin

Walter White picture Walter White · Feb 10, 2010 · Viewed 12.7k times · Source

I cannot seem to get the Maven Glassfish plugin working for the life of me:

<project>
  ...
  <pluginRepositories>
    <pluginRepository>
      <id>glassfish-repository</id>
      <name>Java.net Repository for Glassfish</name>
      <url>http://download.java.net/maven/glassfish</url>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.glassfish</groupId>
        <artifactId>maven-embedded-glassfish-plugin</artifactId>
        <version>3.0</version>

        <configuration>
          <goalPrefix>glassfish</goalPrefix>
          <app>${artifactId}.war</app>
          <contextRoot>${context.root}</contextRoot>
          <port>${http.port}</port>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>  
</project>

When I run mvn glassfish:run, it is looking for a different plugin and cannot find it:

[INFO] The plugin 'org.apache.maven.plugins:maven-glassfish-plugin' does not exist or no valid version could be found

Any ideas?

Answer

Pascal Thivent picture Pascal Thivent · Feb 10, 2010

You're not invoking the right plugin. It should be:

mvn embedded-glassfish:run

Actually, I'm using it like this: (with the same plugin repository you declared):

<plugins>
  <plugin>
    <groupId>org.glassfish</groupId>
    <artifactId>maven-embedded-glassfish-plugin</artifactId>
    <version>3.0</version>
    <configuration>
      <goalPrefix>glassfish</goalPrefix>
      <app>target/test.war</app>
      <port>8080</port>
      <contextRoot>test</contextRoot>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
         <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

Update: Just in case, the fully qualified name of this plugin would be:

mvn org.glassfish:maven-embedded-glassfish-plugin:3.0:run

But using the short name works for me.