Maven Jetty Plugin and double slashes in the url

English The maven jetty plugin is a handy plug-in that allows to run a maven based project that has a web-app inside simply by doing a “mvn jetty:run”, without the hassle of creating a WAR and deploy it to somewhere else.

It happens that the jetty web server, by default, does not handle URLs that contains double slashes “//”, that is, calling http://host/mycontext/media//img/a.gif is not the same as calling http://host/mycontext/media/img/a.gif, and brings a 404 error (as described in http://jira.codehaus.org/browse/JETTY-386)

To enable url compactation in the jetty through maven plug-in, and thus enabling the same behaviour as tomcat:

<plugins>
           ...
           <plugin>
                      <groupId>org.mortbay.jetty</groupId>
                      <artifactId>maven-jetty-plugin</artifactId>
                      <configuration>
                                <scanIntervalSeconds>10</scanIntervalSeconds>
                                <connectors>
                                       <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                               <port>8080</port>
                                               <maxIdleTime>60000</maxIdleTime>
                                       </connector>
                                </connectors>
                                <webAppConfig>
                                       <contextPath>/mycontext</contextPath>
                                       <compactPath>true</compactPath>
                                </webAppConfig>
                    </configuration>
           </plugin>
           ...
</plugins>
Advertisements

One comment on “Maven Jetty Plugin and double slashes in the url

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s