Get maven-jetty plugin to deploy war and serve external static content at the same time
I am writing integration tests for a web application using the maven-jetty plugin. I am using the war deployment target in the pre-integration phase. The web app depends on another web app that I would like to mock by showing static content from the same jetty instance.
here is the relevant part of my jetty config:
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>${jetty.port}</port>
</connector>
</connectors>
<daemon>true</daemon>
<webApp>${build.directory}/motown2-war.war</webApp>
<webAppConfig>
<extraClasspath>${basedir}/target/classes/;${basedir}/target/test-classes</extraClasspath>
<contextPath>/${context.path}</contextPath>
</webAppConfig>
<contextHandlers>
<contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext">
<contextPath>/other</contextPath>
<resourceBase>/opt/data</resourceBase>
</contextHandler>
</contextHandlers>
</configuration>
</execution>
I based this configuration on http://blog.markfeeney.com/2009/12/scala-lift-jetty-6-static-content-and.html , but the configurations for the context handler seem to be ignored. I can't find a trace of this in the log files, jetty is returning 404 instead of static content, web app is running.
What am I missing?
source to share
I understood:
the resourceHandlers config only works for run: run target, so I am currently working with an empty webapp in my test project, which imposes the webapp to be tested:
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>${jetty.port}</port>
</connector>
</connectors>
<daemon>true</daemon>
<webApp>${build.directory}/motown2-war.war</webApp>
<webAppConfig>
<extraClasspath>${basedir}/target/classes/;${basedir}/target/test-classes</extraClasspath>
<contextPath>/${context.path}</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resourcesAsCSV>../motown2-war/src/main/webapp,src/main/webapp</resourcesAsCSV>
</baseResource>
</webAppConfig>
<contextHandlers>
<contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext">
<contextPath>/other</contextPath>
<resourceBase>/opt/data</resourceBase>
</contextHandler>
</contextHandlers>
</configuration>
</execution>
source to share