views:

1177

answers:

3

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&lt;/url&gt;
      <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?

A: 

This problem outcome from fact that 2 differnt maven-glassfish plugins exist with the same name. Try to use

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

Detailed explanatation of this problem you can find here.

cetnar
I think that this blog post is outdated, the embedded plugin is maven-embedded-glassfish-plugin, not maven-glassfish-plugin. See http://blogs.sun.com/sirajg/entry/using_maven_plugin_for_v3
Pascal Thivent
This looks like it is working, I have a few minor tweaks to make.
I am now getting this: java.lang.ClassNotFoundException: org.glassfish.embed.ScatteredWar
@Pascal Yes, you're right. This version seems to be broken.
cetnar
+1  A: 

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.

Pascal Thivent
Pascal, thanks for your answer, but when I try to do that command above, I still get the plugin cannot be found:[INFO] The plugin 'org.apache.maven.plugins:maven-embedded-glassfish-plugin' does not exist or no valid version could be found
@Walter Please post your entire pom because this works for me.
Pascal Thivent
Pascal - sorry for the late reply, but I finally migrated over to Glassfish since it is one of the few Java EE 6 compatible containers. This configuration works well. I had to manually install the artifacts to get them working, but it runs now.
A: 

@Walter White (can't/don't know how to reply to your comment so I'm answering instead): I've read that scattered WAR's are not fully supported by embedded GlassFish v3.

Personally I'm anxiously awaiting v3.1 with Timer and MessageDriven support. Hopefully web service support will be included as well. Does anybody happen to have a clue about an ETA for v3.1?

PS: mvn org.glassfish:maven-embedded-glassfish-plugin:3.0:run works for me. Will hook it up into a proper maven integration-test life cycle now.

Peter