Search code examples
jettymaven-jetty-pluginjetty-9

How do I get deploy-war to work using jetty 9 maven plugin?


In jetty-9 the mvn jetty:deploy-war fails to start the web application. Maven just ends the build, while I expect it to block with a running jetty server. According to the logging output the jetty maven plugin does start a connector on port 8080, and it starts the WebAppContext. It seems to fail binding the port to the context though.

Steps to reproduce:

Create a web app: mvn archetype:generate -DinteractiveMode=false -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=jetty -DartifactId=jetty-demo

Add this plugins-section to the pom:

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.10.v20150310</version>
        </plugin>
    </plugins>
    ...
</build>

Execute:

mvn package

mvn jetty:deploy-war This should start the web app and then block, but it just ends the build

Using jetty-8 all works fine:

<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.16.v20140903</version>

Note: mvn jetty:run-war works as expected in jetty 9. This is the same as deploy-war, but it triggers jetty to build the war before deployment

Reference: the jetty-9 maven plugin manual. And I debugged the jetty startup proces, but without luck so far.


Solution

  • The documentation you linked to tells you why.

    Set the daemon parameter to false and it will block