Jetty-Maven-Plugin reads jettyXml and still starts default context
-
11-12-2019 - |
Question
I am using Jetty 8.1.4.v20120524 and Maven 3. I have the following configuration in my pom:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.4.v20120524</version>
<configuration>
<jettyXml>${project.basedir}/src/main/resources/jetty.xml</jettyXml>
</configuration>
</plugin>
In my jetty.xml, I define a context:
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.HandlerList">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="welcomeFiles">
<Array type="String"><Item>index.xml,index.xhtml,index.html</Item></Array>
</Set>
</New>
</Item>
<Item>
<New id="Contexts" class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="resourceBase"><SystemProperty name="jetty.home" default="src/main/webapp" /></Set>
<Set name="contextPath">/</Set>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
This works as expected and starts my application at /:
INFO:oejs.Server:jetty-8.1.4.v20120524
INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/<MY_DIRECTORY>/src/main/webapp/}
INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/<MY_DIRECTORY>/src/main/webapp/}
However, after this the jetty-maven-plugin seems to try to start a default context, which fails with class not found - It also tries to bind to "/", which I obviously don't want.
WARN:oejs.Holder:java.lang.ClassNotFoundException: org.basex.http.rest.RESTServlet
INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/<MY_DIRECTORY>/src/main/webapp/},file:/<MY_DIRECTORY>/src/main/webapp/
INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/<MY_DIRECTORY>/src/main/webapp/},file:/<MY_DIRECTORY>/src/main/webapp/
INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/<MY_DIRECTORY>/src/main/webapp/},file:/<MY_DIRECTORY>/src/main/webapp/
How can I stop this context to be started? Any help is greatly appreciated.
Solution
According to an Answer on the mailing list (http://dev.eclipse.org/mhonarc/lists/jetty-users/msg02419.html) by Jan Bartel the web app currently can not be configured solely with the jetty.xml.
I therefore resolved the issue by moving the web app related stuff (resource base and context path) to the maven pom.xml.
OTHER TIPS
I was using version 8.1.4.v2012052 of jetty-maven-plugin and attempting to set the contextPath in pom.xml with something like:
<configuration>
<webAppConfig>
<contextPath>${application.contextpath}</contextPath>
</webAppConfig>
...
</configuration>
Yet, the contextPath still defaulted to "/".
I downgraded to version 7.5.1.v20110908 with the same configuration in pom.xml. The intended contextPath did then show.
Thus, I think this may be an issue with the 8.1.4 version that is resolved by downgrading.