Setting "root" context path with Maven Jetty plugin
Asked Answered
T

5

21

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.

Triode answered 31/12, 2011 at 2:48 Comment(0)
G
26

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!!)

Giraffe answered 16/1, 2012 at 13:53 Comment(2)
I removed the bounty, because you were obviously able to figure something out :)Triecious
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.Triode
S
42

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>
Strigose answered 4/11, 2012 at 22:51 Comment(4)
Thanks! They should definitely update the jetty-maven-plugin docs! :-)Chigoe
For Jetty 9 it is the same.Komara
Can you please mention how to set 2 context paths ?Wrongly
Can we give this context path via system property? like -Djetty.port=XXXXDianthus
G
26

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!!)

Giraffe answered 16/1, 2012 at 13:53 Comment(2)
I removed the bounty, because you were obviously able to figure something out :)Triecious
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.Triode
M
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>
Macule answered 15/4, 2015 at 19:32 Comment(0)
F
0

It works! look this :

<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <contextPath>/</contextPath>
    <stopKey>foo</stopKey>
    <stopPort>9999</stopPort>
</configuration>
Fomalhaut answered 3/2, 2012 at 8:35 Comment(0)
E
0
  <plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.2.11.v20150529</version>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <webApp>
         <contextPath>/yourContextPath</contextPath>
    </webApp>    
  </configuration>
  </plugin>
Electrochemistry answered 25/7, 2015 at 19:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.