Tuesday, May 21, 2013

jetty-maven-plugin - ERROR: Cannot override read-only parameter: contextPath in goal: jetty:run

Following error started appear in logs:
[artifact:mvn] [INFO] [compiler:testCompile {execution: default-testCompile}]
[artifact:mvn] [INFO] No sources to compile
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [ERROR] BUILD ERROR
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Error configuring: org.mortbay.jetty:jetty-maven-plugin. Reason: ERROR: Cannot override read-only parameter: contextPath in goal: jetty:run
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] For more information, run Maven with the -e switch
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: 10 seconds
[artifact:mvn] [INFO] Finished at: Tue May 21 14:00:42 CEST 2013
[artifact:mvn] [INFO] Final Memory: 44M/91M

Problem is in pom.xml in jetty-maven-plugin configuration. If there is:

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.5.v20120716</version>
        <configuration>
            <webAppSourceDirectory>${webappDirectory}</webAppSourceDirectory>
            <contextPath>/admin</contextPath>
            ...
        </configuration>
    </plugin>

Than problem is in maven jetty plugin configuration. According to current jetty configuration tag contextPath should be placed inside tag webAppConfig. See following example:

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.5.v20120716</version>
        <configuration>
            <webAppSourceDirectory>${webappDirectory}</webAppSourceDirectory>
            <webAppConfig>
                <contextPath>/admin</contextPath>
            </webAppConfig>
            ...
        </configuration>
    </plugin>

Also see original maven jetty plugin configuration documentation at http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin.

No comments:

Post a Comment