Skip to content

Java Web Application example to replace Tomcat's default ROOT application

License

Notifications You must be signed in to change notification settings

AndriyKalashnykov/tomcat-root-war

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Maven Hits License: MIT

Java Web Application example

ROOT.war replaces Tomcat's default ROOT application - $TOMCAT_HOME/webapps/ROOT

Pre-requisites

  • sdkman

    Install and use JDK 18

    sdk install java 18.0.2-tem
    sdk use java 18.0.2-tem
  • Apache Maven

    Install Apache Maven 3.9.9

    sdk install maven 3.9.9
    sdk use maven 3.9.9
  • git

Test with Jetty web server

git clone git@github.com:AndriyKalashnykov/tomcat-root-war.git
cd tomcat-root-war
mvn clean package jetty:run

xdg-open http://localhost:8080/index.html

Access http://localhost:8080/index.html or see Tomcat ROOT WAR Web Application UI

Create WAR file

git clone git@github.com:AndriyKalashnykov/tomcat-root-war.git
cd tomcat-root-war
mvn clean install

Building WAR in a Secure environmets that enforce SSL

mvn clean install -Daether.connector.https.securityMode=insecure -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true

List content of generated WAR file

jar tf ./target/ROOT.war

Replace TOMCAT ROOT application

Edit $TOMCAT_HOME/conf/server.xml: autoDeploy and deployOnStartUp needs to be set to false

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="false" deployOnStartUp="false">

Remove default ROOT folder and copy ROOT.war

rm -rf $TOMCAT_HOME/webapps/ROOT/
rm -f $TOMCAT_HOME/webapps/ROOT.war
cp ./target/ROOT.war $TOMCAT_HOME/webapps/ROOT.war

Tomcat ROOT WAR Web Application UI

Default welcome page - http://localhost:8080/ index.html

JSP - http://localhost:8080/index.jsp infoservlet

Servlet - http://localhost:8080/infoservlet infoservlet

HTML - http://localhost:8080/index.html infoservlet

This project used in