English 中文(简体)
Maven Embedded Glassfish plugin
原标题:

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?

最佳回答

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.

问题回答

@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.

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.

see on github working example

mvn package embedded-glassfish:run

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.glassfish.embedded</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>3.1.2.2</version>
            <configuration>
                <app>target/${project.artifactId}-${project.version}</app>
                <port>8080</port>
                <contextRoot>${project.artifactId}</contextRoot>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.glassfish.main</groupId>
                    <artifactId>simple-glassfish-api</artifactId>
                    <version>4.0-b79</version>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.main.extras</groupId>
                    <artifactId>glassfish-embedded-all</artifactId>
                    <version>4.0-b83</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>

</build>
<pluginRepositories>
    <pluginRepository>
        <id>maven.java.net</id>
        <name>Java.net Repository for Maven</name>
        <url>https://maven.java.net/content/groups/promoted/</url>
    </pluginRepository>
    <pluginRepository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net Repository for Maven</name>
        <url>http://download.java.net/maven/glassfish/</url>
    </pluginRepository>
</pluginRepositories>




相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签