Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strike>Although it's <a href="https://stackoverflow.com/a/10059792/978502">answered here</a>, thought it would be good to post how the xml should look like:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt; &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt; &lt;version&gt;2.0&lt;/version&gt; &lt;configuration&gt; &lt;path&gt;/myPath&lt;/path&gt; &lt;staticContextPath&gt;/images&lt;/staticContextPath&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>The other answer uses <a href="http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/run-war-only-mojo.html#staticContextDocbase" rel="nofollow noreferrer">staticContextDocbase</a> instead of <a href="http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/run-war-only-mojo.html#staticContextPath" rel="nofollow noreferrer">staticContextPath</a>, and I can't tell the difference between the two, but one of then should work. Haven't tried it myself, though ;)</strike></p> <hr> <p><strong>Tomcat's doc of these two properties:</strong></p> <p>staticContextDocbase:</p> <blockquote> <p>The static context docroot base fully qualified path</p> </blockquote> <p>staticContextPath:</p> <blockquote> <p>The static context</p> </blockquote> <p><strike>Could be that <code>fully qualified path</code> is in contrast to relative path.</strike></p> <hr> <p>Well, I delved a bit into the plugin and Apache's code and found that you need <strong>both</strong> <code>staticContextDocbase</code> and <code>staticContextPath</code>.</p> <p><code>staticContextDocbase</code> is the path from where the static context should be retrieved by Tomcat. In your case it is <code>C:/images</code>.</p> <p><code>staticContextPath</code> is the part in the URL after the <code>http://&lt;hostname&gt;:&lt;port&gt;</code> for which the static context should be sent to client. In your case it is <code>/images</code>.</p> <p>Maven should be configured like so:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.tomcat.maven&lt;/groupId&gt; &lt;artifactId&gt;tomcat7-maven-plugin&lt;/artifactId&gt; &lt;version&gt;2.0&lt;/version&gt; &lt;configuration&gt; &lt;path&gt;/myPath&lt;/path&gt; &lt;staticContextPath&gt;/images&lt;/staticContextPath&gt; &lt;staticContextDocbase&gt;C:/images&lt;/staticContextDocbase&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <hr> <p>Another note:</p> <p><a href="https://fisheye6.atlassian.com/viewrep/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractRunMojo.java?r1=&amp;r2=1312036" rel="nofollow noreferrer">As seen here</a>, the plugin uses <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.0/org/apache/catalina/startup/Tomcat.java#Tomcat.addContext%28java.lang.String%2Cjava.lang.String%29" rel="nofollow noreferrer"><code>Tomcat.addContext(String contextPath, String baseDir)</code></a>, <code>staticContextPath</code> is passed as <code>contextPath</code> and <code>staticContextDocbase</code> is passed as <code>baseDir</code>. The doc for <code>baseDir</code> states that it <code>Must exist, relative to the server home</code>.</p> <p>OTOH, that <code>baseDir</code> is moved as is to <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.0/org/apache/catalina/Context.java#Context.setDocBase%28java.lang.String%29" rel="nofollow noreferrer"><code>Context.setBaseDir(String docBase)</code></a>. The doc on <em>that</em> method for <code>baseDir</code> states that <code>This can be an absolute pathname, a relative pathname, or a URL.</code>.</p> <p>Try the full path then. If it doesn't work go for the relative ;).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload