blob: 0ed869eafbc73e76d2e9f0edaff3f80cc276abcf [file]
<?xml version="1.0"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<document xmlns="http://maven.apache.org/XDOC/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<properties>
<title>Apache Tomcat 11 + Axis2 HTTP/2 Integration Guide - Production-Ready Configuration</title>
</properties>
<body>
<h1>Apache Tomcat 11 + Axis2 HTTP/2 Integration Guide</h1>
<div style="background-color: #e8f5e8; border: 1px solid #4CAF50; padding: 15px; margin: 10px 0;">
<h4>🚀 Apache Tomcat 11 HTTP/2 - Excellent Support with Simplified Configuration</h4>
<h2>Tomcat 11 HTTP/2 Configuration (Production-Optimized)</h2>
<h3>1. Complete server.xml HTTP/2 Configuration</h3>
<pre>
&lt;!-- Apache Tomcat 11 - HTTP/2 Optimized Configuration --&gt;
&lt;!-- Aligned with Axis2 Enhanced Moshi H2 Processing --&gt;
&lt;Server port="8005" shutdown="SHUTDOWN"&gt;
&lt;!-- Global Naming Resources --&gt;
&lt;GlobalNamingResources&gt;
&lt;Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" /&gt;
&lt;/GlobalNamingResources&gt;
&lt;!-- Thread Pool for HTTP/2 Optimization --&gt;
&lt;!-- Aligned with Axis2 Enhanced Moshi H2 async processing --&gt;
&lt;Service name="Catalina"&gt;
&lt;!-- HTTP/2 Thread Pool Configuration --&gt;
&lt;Executor name="tomcatThreadPool"
namePrefix="catalina-exec-"
maxThreads="200" &lt;!-- Matches HTTP/2 concurrent streams --&gt;
minSpareThreads="20"
maxIdleTime="600000" &lt;!-- 10 minutes --&gt;
prestartminSpareThreads="true" /&gt;
&lt;!-- HTTP Connector with HTTP/2 Upgrade --&gt;
&lt;Connector executor="tomcatThreadPool"
port="8080"
protocol="HTTP/1.1"
redirectPort="8443"
maxPostSize="104857600" &lt;!-- 100MB for large JSON payloads --&gt;
connectionTimeout="300000" &lt;!-- 5 minutes for large payload processing --&gt;
keepAliveTimeout="300000" &lt;!-- Keep-alive for performance --&gt;
maxKeepAliveRequests="1000" &lt;!-- High keep-alive for HTTP/2 benefits --&gt;
compression="on" &lt;!-- JSON compression --&gt;
compressionMinSize="2048" &lt;!-- Compress &gt;2KB JSON --&gt;
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css" /&gt;
&lt;!-- HTTPS Connector with Native HTTP/2 Support --&gt;
&lt;!-- PRODUCTION-OPTIMIZED: Native HTTP/2 implementation --&gt;
&lt;Connector executor="tomcatThreadPool"
port="8443"
protocol="org.apache.coyote.http11.Http11AprProtocol"
maxPostSize="104857600" &lt;!-- 100MB for large JSON --&gt;
SSLEnabled="true"
scheme="https"
secure="true"
connectionTimeout="300000" &lt;!-- 5 minutes --&gt;
keepAliveTimeout="300000" &lt;!-- Persistent connections --&gt;
&lt;!-- HTTP/2 Configuration Parameters --&gt;
&lt;!-- ALIGNED: Buffer sizes match Enhanced Moshi H2 --&gt;
upgradeAsyncTimeout="300000" &lt;!-- HTTP/2 upgrade timeout --&gt;
http2MaxConcurrentStreams="200" &lt;!-- High concurrency --&gt;
http2InitialWindowSize="2097152" &lt;!-- 2MB: avoids flow-control round trips --&gt;
http2MaxFrameSize="32768" &lt;!-- 32KB - aligned with buffer management --&gt;
http2MaxHeaderTableSize="8192" &lt;!-- 8KB header table --&gt;
http2MaxHeaderListSize="32768" &lt;!-- 32KB header list --&gt;
http2EnablePush="false" &lt;!-- Disabled for web services --&gt;
&lt;!-- SSL Configuration --&gt;
SSLCertificateFile="/path/to/your/certificate.crt"
SSLCertificateKeyFile="/path/to/your/private.key"
SSLCertificateChainFile="/path/to/your/chain.crt"
SSLProtocol="TLSv1.2+TLSv1.3" &lt;!-- Modern TLS for HTTP/2 --&gt;
SSLCipherSuite="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384"
SSLHonorCipherOrder="true"
&lt;!-- JSON Processing Optimization --&gt;
compression="on"
compressionMinSize="2048"
compressableMimeType="application/json,application/xml" /&gt;
&lt;!-- Engine Configuration --&gt;
&lt;Engine name="Catalina" defaultHost="localhost"&gt;
&lt;!-- Host Configuration with HTTP/2 Access Logging --&gt;
&lt;Host name="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"&gt;
&lt;!-- HTTP/2 + JSON Performance Access Log --&gt;
&lt;Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="axis2_http2_access_log"
suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b %D Protocol:%{org.apache.coyote.request.protocol}r JSON-Size:%{Content-Length}o Time:%T"
resolveHosts="false" /&gt;
&lt;!-- JSON Compression for Axis2 Responses --&gt;
&lt;Context&gt;
&lt;Valve className="org.apache.catalina.valves.rewrite.RewriteValve" /&gt;
&lt;/Context&gt;
&lt;/Host&gt;
&lt;/Engine&gt;
&lt;/Service&gt;
&lt;/Server&gt;
</pre>
<h3>2. Key Configuration Highlights</h3>
<table border="1">
<tr><th>Parameter</th><th>Tomcat 11 Value</th><th>Optimization Purpose</th><th>WildFly Equivalent</th></tr>
<tr><td><strong>http2MaxConcurrentStreams</strong></td><td>200</td><td>High multiplexing for large JSON APIs</td><td>http2-max-concurrent-streams="200"</td></tr>
<tr><td><strong>http2InitialWindowSize</strong></td><td>2097152 (2MB)</td><td>Avoids flow-control round trips on large responses</td><td>http2-initial-window-size="2097152"</td></tr>
<tr><td><strong>http2MaxFrameSize</strong></td><td>32768 (32KB)</td><td>Optimal for JSON streaming</td><td>http2-max-frame-size="32768"</td></tr>
<tr><td><strong>maxPostSize</strong></td><td>104857600 (100MB)</td><td>Large JSON payload support</td><td>max-post-size="104857600"</td></tr>
<tr><td><strong>connectionTimeout</strong></td><td>300000 (5min)</td><td>Large payload processing time</td><td>no-request-timeout="300000"</td></tr>
<tr><td><strong>http2EnablePush</strong></td><td>false</td><td>Disabled for web services</td><td>http2-enable-push="false"</td></tr>
</table>
<h2>Axis2 Integration Configuration</h2>
<h3>1. Enhanced axis2.xml for Tomcat HTTP/2</h3>
<pre>
&lt;!-- axis2.xml - Tomcat 11 + HTTP/2 + Enhanced Moshi H2 Configuration --&gt;
&lt;axisconfig name="AxisJava2.0-Tomcat11-HTTP2-EnhancedMoshiH2"&gt;
&lt;!-- JSON processing mode and Tomcat HTTP/2 tuning are configured in
Tomcat's server.xml (compression, keep-alive, buffer sizes, etc.),
not in axis2.xml. Use the standard JSON message builder below. --&gt;
&lt;!-- Enhanced JSON Message Builder --&gt;
&lt;messageBuilder contentType="application/json"
class="org.apache.axis2.json.moshih2.EnhancedMoshiJsonBuilder"/&gt;
&lt;!-- Enhanced JSON Message Formatter --&gt;
&lt;messageFormatter contentType="application/json"
class="org.apache.axis2.json.moshih2.EnhancedMoshiJsonFormatter"/&gt;
&lt;!-- HTTP/1.1 Transport (Fallback) --&gt;
&lt;transportSender name="http"
class="org.apache.axis2.transport.http.impl.httpclient5.HTTPClient5TransportSender"&gt;
&lt;parameter name="PROTOCOL"&gt;HTTP/1.1&lt;/parameter&gt;
&lt;/transportSender&gt;
&lt;!-- HTTP/2 Transport (Coordinated with Tomcat 11) --&gt;
&lt;transportSender name="h2"
class="org.apache.axis2.transport.h2.impl.httpclient5.H2TransportSender"&gt;
&lt;parameter name="PROTOCOL"&gt;HTTP/2.0&lt;/parameter&gt;
&lt;!-- Coordination with Tomcat 11 HTTP/2 --&gt;
&lt;parameter name="maxConcurrentStreams"&gt;200&lt;/parameter&gt; &lt;!-- Matches Tomcat --&gt;
&lt;parameter name="initialWindowSize"&gt;2097152&lt;/parameter&gt; &lt;!-- 2MB: avoids flow-control round trips --&gt;
&lt;parameter name="maxFrameSize"&gt;32768&lt;/parameter&gt; &lt;!-- 32KB - matches Tomcat --&gt;
&lt;parameter name="maxConnectionsTotal"&gt;50&lt;/parameter&gt;
&lt;parameter name="maxConnectionsPerRoute"&gt;10&lt;/parameter&gt;
&lt;parameter name="connectionTimeout"&gt;60000&lt;/parameter&gt; &lt;!-- 1 minute connection --&gt;
&lt;parameter name="responseTimeout"&gt;300000&lt;/parameter&gt; &lt;!-- 5min response timeout --&gt;
&lt;!-- JSON streaming and compression are handled by the message formatter
and Tomcat's server.xml respectively — no additional transport
sender parameters are needed for Moshi or Tomcat integration. --&gt;
&lt;/transportSender&gt;
&lt;/axisconfig&gt;
</pre>
<h2>Advanced Configuration Options</h2>
<h3>1. SSL/TLS Certificate Setup</h3>
<p><strong>Tomcat 11 simplifies SSL setup compared to WildFly</strong>:</p>
<h4>Option A: APR/Native SSL (Recommended for Production)</h4>
<pre>
# Install Tomcat Native Library (Ubuntu/Debian)
sudo apt-get install libtcnative-1 openssl-dev
# Certificate configuration in server.xml
SSLCertificateFile="/etc/ssl/certs/your-domain.crt"
SSLCertificateKeyFile="/etc/ssl/private/your-domain.key"
SSLCertificateChainFile="/etc/ssl/certs/chain.crt"
</pre>
<h4>Option B: Java KeyStore SSL</h4>
<pre>
# Generate keystore
keytool -genkeypair -keyalg RSA -keysize 2048 -keystore tomcat-keystore.jks \
-alias tomcat -dname "CN=your-domain.com,OU=IT,O=YourOrg,C=US"
# Server.xml configuration
&lt;Connector port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxPostSize="104857600"
SSLEnabled="true"
keystoreFile="/path/to/tomcat-keystore.jks"
keystorePass="your-password"
keyAlias="tomcat" /&gt;
</pre>
<h3>2. Memory Optimization for HTTP/2 + JSON Processing</h3>
<h4>JVM Memory Settings (catalina.sh)</h4>
<pre>
# Memory-optimized JVM settings for HTTP/2 + Enhanced Moshi H2
export CATALINA_OPTS="$CATALINA_OPTS -Xms2048m -Xmx4096m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:+UseG1GC"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxGCPauseMillis=200"
export CATALINA_OPTS="$CATALINA_OPTS -XX:G1HeapRegionSize=16m"
# HTTP/2 Connection Pool Optimization
export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv6Addresses=false"
export CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.coyote.http2.Http2Protocol.maxConcurrentStreams=200"
# Enhanced Moshi H2 Optimization
export CATALINA_OPTS="$CATALINA_OPTS -Daxis2.json.moshi.h2.enabled=true"
export CATALINA_OPTS="$CATALINA_OPTS -Daxis2.json.moshi.h2.async.threshold=1048576"
</pre>
<h3>3. Production Monitoring Configuration</h3>
<h4>Enhanced Access Logging</h4>
<pre>
&lt;!-- HTTP/2 + JSON Performance Monitoring --&gt;
&lt;Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="http2_performance"
suffix=".log"
pattern="%h %u %t &quot;%r&quot; %s %b %D Protocol:%{org.apache.coyote.request.protocol}r
Streams:%{http2.concurrent.streams}r
JSON-Size:%{Content-Length}o
Moshi-Processing:%{X-Moshi-H2-Processing-Time}o
Compression:%{Accept-Encoding}i" /&gt;
</pre>
<h2>Production Deployment Guide</h2>
<h3>1. Step-by-Step Deployment</h3>
<h4>Step 1: Install Tomcat 11</h4>
<pre>
# Download and extract Tomcat 11
cd /opt
sudo wget https://downloads.apache.org/tomcat/tomcat-11/v11.0.x/bin/apache-tomcat-11.0.x.tar.gz
sudo tar -xzf apache-tomcat-11.0.x.tar.gz
sudo mv apache-tomcat-11.0.x tomcat11
sudo chown -R tomcat:tomcat /opt/tomcat11
</pre>
<h4>Step 2: Configure HTTP/2 (Replace server.xml)</h4>
<pre>
# Backup original configuration
sudo cp /opt/tomcat11/conf/server.xml /opt/tomcat11/conf/server.xml.backup
# Apply HTTP/2 optimized configuration (use the server.xml above)
sudo nano /opt/tomcat11/conf/server.xml
</pre>
<h4>Step 3: Deploy Axis2 with Enhanced Moshi H2</h4>
<pre>
# Deploy your Axis2 WAR with Enhanced Moshi H2
sudo cp your-axis2-app.war /opt/tomcat11/webapps/
# Configure axis2.xml with HTTP/2 settings (use configuration above)
# Update WEB-INF/conf/axis2.xml in your deployed WAR
</pre>
<h4>Step 4: Configure SSL Certificates</h4>
<pre>
# Place certificates in secure location
sudo mkdir -p /etc/tomcat11/ssl
sudo cp your-domain.crt /etc/tomcat11/ssl/
sudo cp your-domain.key /etc/tomcat11/ssl/
sudo chown -R tomcat:tomcat /etc/tomcat11/ssl
sudo chmod 600 /etc/tomcat11/ssl/*
</pre>
<h4>Step 5: Start and Validate</h4>
<pre>
# Start Tomcat
sudo systemctl start tomcat11
# Validate HTTP/2 is working
curl -k --http2 --location 'https://localhost:8443/your-app/services/YourService' \
--header 'Content-Type: application/json' \
--data '{"test": "HTTP/2 validation"}' \
--trace-ascii trace.log
# Check for HTTP/2 in trace.log
grep "HTTP/2" trace.log
</pre>
<h3>2. Performance Validation</h3>
<h4>Validate HTTP/2 Protocol Negotiation</h4>
<pre>
# Test HTTP/2 negotiation
openssl s_client -connect localhost:8443 -alpn h2
# Expected output should show:
# ALPN protocol: h2
# Protocol: TLSv1.3
</pre>
<h4>Test Large JSON Payload Processing</h4>
<pre>
# Test large payload with Enhanced Moshi H2
curl -k --http2 -X POST 'https://localhost:8443/your-app/services/JsonService' \
--header 'Content-Type: application/json' \
--data @large-test-payload.json \
--output response.json \
--write-out "Time: %{time_total}s, Size: %{size_download} bytes, HTTP: %{http_version}\n"
# Should show HTTP/2.0 and fast processing times
</pre>
<h3>3. Monitoring and Troubleshooting</h3>
<h4>HTTP/2 Metrics Monitoring</h4>
<pre>
# Monitor access logs for HTTP/2 performance
tail -f /opt/tomcat11/logs/http2_performance.log
# Key metrics to watch:
# - Protocol: HTTP/2.0
# - Concurrent streams usage
# - JSON processing times
# - Compression ratios
</pre>
<h4>JVM Performance Monitoring</h4>
<pre>
# Monitor JVM metrics
jstat -gc -t $(pgrep -f tomcat) 5s
# Monitor HTTP/2 connections
netstat -an | grep :8443 | grep ESTABLISHED | wc -l
</pre>
</div>
</body>
</document>