Apache Tomcat Maven Plugin
  1. Apache Tomcat Maven Plugin
  2. MTOMCAT-217

configure a pre define http port for standalone jar

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta-1, 2.1
    • Fix Version/s: 2.2
    • Component/s: tomcat7
    • Labels:
      None
    • Environment:
      Windows7, maven2.2.1, JDK-Oracle 7.0_u15

      Description

      I use maven-tomcat-plugin to create war-exec.jar with following definition:
      <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.2-SNAPSHOT</version>
      <configuration>
      <serverXml>src/main/tomcat/server.xml</serverXml>
      </configuration>
      <executions>
      <execution>
      <id>create-exec-war</id>
      <goals>
      <goal>exec-war-only</goal>
      </goals>
      <phase>package</phase>
      </execution>
      </executions>
      </plugin>

      But when the server.xml is specified - to configure some defaults for server like NIO, etc. than the CLI parameters are ignored:

      java -jar war-exec.jar -httpPort 8888

      does not change the the server port.

        Activity

        Hide
        Hudson added a comment -

        UNSTABLE: Integrated in TomcatMavenPlugin-mvn3.x #260 (See https://builds.apache.org/job/TomcatMavenPlugin-mvn3.x/260/)
        MTOMCAT-217 configure a pre define http port for standalone jar (olamy: http://svn.apache.org/viewvc/?view=rev&rev=1537827)

        • /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
        • /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
        • /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java
        Show
        Hudson added a comment - UNSTABLE: Integrated in TomcatMavenPlugin-mvn3.x #260 (See https://builds.apache.org/job/TomcatMavenPlugin-mvn3.x/260/ ) MTOMCAT-217 configure a pre define http port for standalone jar (olamy: http://svn.apache.org/viewvc/?view=rev&rev=1537827 ) /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        fixed
        httpPort will be the mojo field.

        Show
        Olivier Lamy (*$^¨%`£) added a comment - fixed httpPort will be the mojo field.
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        Move it as a new feature as it's not supported currently see parameters http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/exec-war-mojo.html
        BTW see http://tomcat.apache.org/maven-plugin-2.1/executable-war-jar.html you can use cli parameter: -httpPort

        Show
        Olivier Lamy (*$^¨%`£) added a comment - Move it as a new feature as it's not supported currently see parameters http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/exec-war-mojo.html BTW see http://tomcat.apache.org/maven-plugin-2.1/executable-war-jar.html you can use cli parameter: -httpPort
        Hide
        Petr Novak added a comment -

        Thanks for your comment.

        I try to better explain my motivation and change the scenario to avoid use of server.xml, but there is still other problem.

        In my scenario I want to build a self-executing JAR with PORT predefined to 8042 and distribute it to my users, but users should still have the possibility to simply change the default port in their environment, when needed.

        I try this:

        <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <configuration>
        <port>8042</port>
        </configuration>
        <executions>
        <execution>
        <id>create-exec-war</id>
        <goals>
        <goal>exec-war-only</goal>
        </goals>
        <phase>package</phase>
        </execution>
        </executions>
        </plugin>

        No server.xml configuration, only PORT definition and I assumed that the port will be persisted in tomcat.standalone.properties as other parameters for exec.jar and used as default for the execution, but not, the default 8080 was used instead. And if this will be possible, than should be also possible to use -httpPort=9090 to change the internal default value from build (serialized in tomcat.standalone.properties).

        So I could avoid to define my own server.xml, but I need to have possibility to specify default values for all CLI parameters during maven-build time (in pom definition).

        Show
        Petr Novak added a comment - Thanks for your comment. I try to better explain my motivation and change the scenario to avoid use of server.xml, but there is still other problem. In my scenario I want to build a self-executing JAR with PORT predefined to 8042 and distribute it to my users, but users should still have the possibility to simply change the default port in their environment, when needed. I try this: <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8042</port> </configuration> <executions> <execution> <id>create-exec-war</id> <goals> <goal>exec-war-only</goal> </goals> <phase>package</phase> </execution> </executions> </plugin> No server.xml configuration, only PORT definition and I assumed that the port will be persisted in tomcat.standalone.properties as other parameters for exec.jar and used as default for the execution, but not, the default 8080 was used instead. And if this will be possible, than should be also possible to use -httpPort=9090 to change the internal default value from build (serialized in tomcat.standalone.properties). So I could avoid to define my own server.xml, but I need to have possibility to specify default values for all CLI parameters during maven-build time (in pom definition).
        Hide
        Jason McIntosh added a comment -

        Off hand, a server.xml would bypass those CLI settings, as server.xml is where those settings are normally defined. Sounds more like an enhancement (and a complicated one) to allow command line arguments to overload a complicated (potentially) server.xml configuration. I think the assumption would be if you really want to use a custom server.xml you'll need to define the host/port settings in your server.xml file.

        Show
        Jason McIntosh added a comment - Off hand, a server.xml would bypass those CLI settings, as server.xml is where those settings are normally defined. Sounds more like an enhancement (and a complicated one) to allow command line arguments to overload a complicated (potentially) server.xml configuration. I think the assumption would be if you really want to use a custom server.xml you'll need to define the host/port settings in your server.xml file.

          People

          • Assignee:
            Olivier Lamy (*$^¨%`£)
            Reporter:
            Petr Novak
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development