Apache Tomcat Maven Plugin :: Tomcat 8.x War Runner

Tomcat 8.x runner for exec-wars generated by Tomcat 7 Maven plugin

License

License

Categories

Categories

Tomcat Container Application Servers
GroupId

GroupId

com.nitorcreations
ArtifactId

ArtifactId

tomcat8-war-runner
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Apache Tomcat Maven Plugin :: Tomcat 8.x War Runner
Tomcat 8.x runner for exec-wars generated by Tomcat 7 Maven plugin
Project URL

Project URL

https://github.com/NitorCreations/tomcat8-war-runner
Source Code Management

Source Code Management

https://github.com/NitorCreations/tomcat8-war-runner

Download tomcat8-war-runner

How to add to project

<!-- https://jarcasting.com/artifacts/com.nitorcreations/tomcat8-war-runner/ -->
<dependency>
    <groupId>com.nitorcreations</groupId>
    <artifactId>tomcat8-war-runner</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.nitorcreations/tomcat8-war-runner/
implementation 'com.nitorcreations:tomcat8-war-runner:1.0'
// https://jarcasting.com/artifacts/com.nitorcreations/tomcat8-war-runner/
implementation ("com.nitorcreations:tomcat8-war-runner:1.0")
'com.nitorcreations:tomcat8-war-runner:jar:1.0'
<dependency org="com.nitorcreations" name="tomcat8-war-runner" rev="1.0">
  <artifact name="tomcat8-war-runner" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.nitorcreations', module='tomcat8-war-runner', version='1.0')
)
libraryDependencies += "com.nitorcreations" % "tomcat8-war-runner" % "1.0"
[com.nitorcreations/tomcat8-war-runner "1.0"]

Dependencies

compile (16)

Group / Artifact Type Version
commons-cli : commons-cli jar 1.2
org.apache.tomcat.embed : tomcat-embed-core jar 8.0.23
org.apache.tomcat : tomcat-util jar 8.0.23
org.apache.tomcat : tomcat-coyote jar 8.0.23
org.apache.tomcat : tomcat-api jar 8.0.23
org.apache.tomcat : tomcat-jdbc jar 8.0.23
org.apache.tomcat : tomcat-dbcp jar 8.0.23
org.apache.tomcat : tomcat-servlet-api jar 8.0.23
org.apache.tomcat : tomcat-jsp-api jar 8.0.23
org.apache.tomcat : tomcat-jasper jar 8.0.23
org.apache.tomcat : tomcat-jasper-el jar 8.0.23
org.apache.tomcat : tomcat-el-api jar 8.0.23
org.apache.tomcat : tomcat-catalina jar 8.0.23
org.apache.tomcat : tomcat-tribes jar 8.0.23
org.apache.tomcat : tomcat-catalina-ha jar 8.0.23
org.apache.tomcat : tomcat-annotations-api jar 8.0.23

Project Modules

There are no modules declared in this project.

tomcat8-war-runner

Introduction

Currently there exists no Tomcat 8 version of Tomcat Maven plugin. Exec-wars built using Tomcat 7 Maven plugin work on Tomcat 8, except if you want to use a custom server.xml.

In addition to fixing the issue with server.xml, this runner sets the exec-war parameters affecting Tomcat configuration to system properties, when a custom server.xml is detected. This enables you to refer them in the custom server.xml and smoothly switch between having and not having a custom server.xml.

The runner also adds more options to command line configuration.

Usage

The runner is published to Maven Central, so just add it as extra dependency for tomcat7-maven-plugin.

  • Configure you tomcat7-maven-plugin to use this runner in your web project pom.xml:
<plugin>
  <groupId>org.apache.tomcat.maven</groupId>
  <artifactId>tomcat7-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>build-exec-war</id>
      <configuration>
        <path>/app/v1</path>
        <mainClass>org.apache.tomcat.maven.runner.Tomcat8RunnerCli</mainClass>
        <extraDependencies>
          <extraDependency>
            <groupId>com.nitorcreations</groupId>
            <artifactId>tomcat8-war-runner</artifactId>
            <version>1.0</version>
          </extraDependency>
        </extraDependencies>
      </configuration>
    </execution>
  </executions>
</plugin>
  • Create your custom server.xml file to your web project directory src/main/tomcatconf/server.xml. For example:
<Server port="8010" shutdown="SHUTDOWN">
  <GlobalNamingResources></GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="${httpPort}" maxThreads="${maxThreads}" protocol="HTTP/1.1"/>
    <Engine name="Catalina" defaultHost="localhost">
      <Valve className="org.apache.catalina.valves.AccessLogValve" 
             pattern="%h %l %u %t &quot;%r&quot; %s %D %b &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot;"/>
      <Valve className="org.apache.catalina.valves.RemoteIpValve"/> 
      <Host name="localhost" appBase="webapps">
        <Context path="/app/v1" docBase="app/v1.war"/>
      </Host>
    </Engine>
  </Service>
</Server>
  • After rebuilding your web project, you can run and configure your app-webapp-1.0-SNAPSHOT-war-exec.jar by mixing default Tomcat Maven plugin parameters (httpPort) and/or system properties (maxThreads) depending on your needs. (System properties take precedence over default Tomcat Maven plugin parameters, if both are defined.)
java -DmaxThreads=300 -jar app-webapp-1.0-SNAPSHOT-war-exec.jar -httpPort 9999
  • Supported command line parameters:
usage: java -jar [path to your exec war jar]
 -accessLogDirectory <accessLogDirectory>   directory for access log files
 -ajpPort <ajpPort>                         ajp port to use
 -clientAuth                                enable client authentication
                                            for https
 -D <arg>                                   key=value
 -extractDirectory <extractDirectory>       path to extract war content,
                                            default value: .extract
 -h,--help                                  help
 -httpPort <httpPort>                       http port to use
 -httpProtocol <httpProtocol>               http protocol to use: HTTP/1.1
                                            or
                                            org.apache.coyote.http11.Http1
                                            1NioProtocol
 -httpsPort <httpsPort>                     https port to use
 -keyAlias <keyAlias>                       alias from keystore for ssl
 -loggerName <loggerName>                   logger to use: slf4j to use
                                            slf4j bridge on top of jul
 -maxPostSize <maxPostSize>                 max post size to use
 -obfuscate <password>                      obfuscate the password and
                                            exit
 -proxyName <proxyName>                     pretend requests are coming to
                                            this hostname
 -proxyPort <proxyPort>                     pretend requests are coming to
                                            this port
 -resetExtract                              clean previous extract
                                            directory
 -s,--secure                                if requests are considered
                                            secure (should be used with
                                            scheme https)
 -scheme <scheme>                           scheme to use: http or https
 -serverXmlPath <serverXmlPath>             server.xml to use, optional
 -sessionManagerFactory <className>         classname of a factory that
                                            creates a session manager
 -uriEncoding <uriEncoding>                 connector uriEncoding default
                                            ISO-8859-1
 -X,--debug                                 debug
com.nitorcreations

Nitor Creations

Versions

Version
1.0