Jetty-Maven-Plugin lê jettyXml e ainda inicia o contexto padrão
-
11-12-2019 - |
Pergunta
Estou usando Jetty 8.1.4.v20120524 e Maven 3.Tenho a seguinte configuração no meu 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>
No meu jetty.xml, defino um contexto:
<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>
Isso funciona conforme o esperado e inicia meu aplicativo em /:
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/}
No entanto, depois disso, o plugin jetty-maven parece tentar iniciar um contexto padrão, que falha com a classe não encontrada - ele também tenta vincular a "/", o que obviamente não quero.
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/
Como posso impedir que esse contexto seja iniciado?Qualquer ajuda é muito apreciada.
Solução
De acordo com uma resposta na lista de discussão (http://dev.eclipse.org/mhonarc/lists/jetty-users/msg02419.html) de Jan Bartel, o aplicativo da web atualmente não pode ser configurado apenas com jetty.xml.
Portanto, resolvi o problema movendo o material relacionado ao aplicativo da web (base de recursos e caminho de contexto) para o maven pom.xml.
Outras dicas
Eu estava usando a versão 8.1.4.v2012052 do jetty-maven-plugin e tentando definir o contextPath em pom.xml com algo como:
<configuration>
<webAppConfig>
<contextPath>${application.contextpath}</contextPath>
</webAppConfig>
...
</configuration>
No entanto, o contextPath ainda é padronizado como "/".
Fiz downgrade para a versão 7.5.1.v20110908 com a mesma configuração em pom.xml.O contextPath pretendido foi então exibido.
Portanto, acho que isso pode ser um problema com a versão 8.1.4 que é resolvido com o downgrade.