Setting "root" context path with Maven Jetty plugin

20,924

Solution 1

This works for me with Jetty 6 (Version 8 and 9 see the answer from Michael McCallum):

           <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.22</version>
                <configuration>
                    <contextPath>/</contextPath>                     
                </configuration>
                ...
            </plugin>

Hope it helps.

(Typically I got it working just after offering the bounty!!)

Solution 2

FWIW this is what you need for jetty 8

<plugin>
 <groupId>org.mortbay.jetty</groupId>
 <artifactId>jetty-maven-plugin</artifactId>
 <version>8.1.7.v20120910</version>
 <configuration>       
   <webApp>
    <contextPath>/</contextPath>
  </webApp>
 </configuration>
</plugin>

Solution 3


Really works (current version example):

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.0.M2</version>
    <configuration>
    <webApp>
        <contextPath>/${path}</contextPath>
    </webApp>
    </configuration>
</plugin>
Share:
20,924
Thomas Vervik
Author by

Thomas Vervik

Head of Development Bipper Communications

Updated on July 26, 2020

Comments

  • Thomas Vervik
    Thomas Vervik almost 4 years

    I have the following Maven code snippet

    <plugin>
      <!-- http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin -->
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>maven-jetty-plugin</artifactId>
      <version>6.1.16</version>
      <configuration>
        <contextPath>/thomas</contextPath>
        <stopPort>9966</stopPort>
        <stopKey>foo</stopKey>
      </configuration>
    </plugin>
    

    I want to set context path to "/" but the Jetty plugin doesn't respect it, the context falls back to using the folder (or maybe the module) name as the context path. If I set a context path with a name, for example:

     <contextPath>/thomas</contextPath>
    

    Any suggestions?

    Thanks in advance.

  • Tim Post
    Tim Post over 12 years
    I removed the bounty, because you were obviously able to figure something out :)
  • Thomas Vervik
    Thomas Vervik over 12 years
    sorry vert late reply, I tried <contextPath>/</contextPath>, but I didnt get it to work, but if it works on your side I maybe should look if there is something else which is wrong.
  • sergiofbsilva
    sergiofbsilva over 11 years
    Thanks! They should definitely update the jetty-maven-plugin docs! :-)
  • niels
    niels over 10 years
    For Jetty 9 it is the same.
  • Débora
    Débora about 8 years
    Can you please mention how to set 2 context paths ?
  • Jaraws
    Jaraws over 2 years
    Can we give this context path via system property? like -Djetty.port=XXXX