views:

22

answers:

1

Yesterday,I read the glassfish embed example this address is: http://weblogs.java.net/blog/arungupta/archive/2008/11/totd_56_simple.html

but I running the command glassfish:run had a error message

No plugin found for prefix 'glassfish' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

My pom.xml is

<dependencies>
<dependency>
        <groupId>org.glassfish.distributions</groupId>
        <artifactId>web-all</artifactId>
        <version>10.0-SNAPSHOT</version>
        <type>jar</type>
        <classifier>build</classifier>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.embedded</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
        <version>3.0-Prelude-SNAPSHOT</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>utf-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.glassfish.maven.plugin</groupId>
            <artifactId>maven-glassfish-plugin</artifactId>

        </plugin>
    </plugins>
    <finalName>SSH2Maven</finalName>
</build>
<pluginRepositories>
    <pluginRepository>
        <id>ocean glassfish</id>
        <url>http://maven.ocean.net.au/snapshot&lt;/url&gt;
        <releases>
            <enabled>false</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
<repositories>
    <repository>
        <id>glassfish repo</id>
        <url>http://maven.glassfish.org/content/groups/glassfish&lt;/url&gt;
    </repository>
</repositories>

Why? Plz give me a full pom.xml example,thx.

+1  A: 

As I suspected in a previous answer, the stuff you are using and the tutorial you're following is outdated (GlassFish v3 Prelude precedes GlassFish v3 which has been released in december 2009 and updated with the recent release of GlassFish 3.0.1) and things like Maven plugins have changed since then.

So, while it should be possible to get things working, I'm not going to spend some time trying :) Instead, here is an up to date (minimal) configuration for the maven-embedded-glassfish-plugin:

<project>
  ...
  <pluginRepositories>
    <pluginRepository>
      <id>m.g.o-groups-glassfish</id>
      <url>http://maven.glassfish.org/content/groups/glassfish&lt;/url&gt;
    </pluginRepository>
  </pluginRepositories>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.glassfish</groupId>
        <artifactId>maven-embedded-glassfish-plugin</artifactId>
        <version>3.0.1</version>
        <configuration>
          <app>${project.build.directory}/${build.finalName}.war</app>
          <autoDelete>true</autoDelete>
          <port>8080</port>
          <contextRoot>test</contextRoot>
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
  </build>
</project>

Then run:

mvn embedded-glassfish:run

And point your browser on http://localhost:8080/test.

Pascal Thivent
EdwardLau