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</url>
        <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</url>
    </repository>
</repositories>

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

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
EdwardLau
  • 1,139
  • 4
  • 20
  • 26

2 Answers2

2

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</url>
    </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.

Community
  • 1
  • 1
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Oh,I had read "To Set Up Your Maven Environment(http://docs.sun.com/app/docs/doc/821-1208/gihus?l=en&a=view)" in yesterday,but I search By Google all is examples . So I want to trying tihs examples .Thank you very much for answer. – EdwardLau Jun 26 '10 at 14:36
0

Here is the latest <plugin> for running Embedded GlassFish 4.0:

<plugin>
            <groupId>org.glassfish.embedded</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>4.0</version>
            <configuration>
                <app>target/${project.artifactId}.war</app>
                <port>8080</port>
                <ports>
                    <https-listener>8181</https-listener>
                </ports>       
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.glassfish.main.common</groupId>
                    <artifactId>simple-glassfish-api</artifactId>
                    <version>4.0</version>
                </dependency>                    
                <dependency>
                    <groupId>org.glassfish.main.extras</groupId>
                    <artifactId>glassfish-embedded-all</artifactId>
                    <version>4.0</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>start</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>start</goal>
                        <goal>deploy</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stop</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>undeploy</goal>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

See a working sample at:

https://github.com/arun-gupta/javaee7-samples/

Arun Gupta
  • 3,965
  • 5
  • 31
  • 39