1. Home
  2. Custom Installation
  3. Install Method 3 – Using External Tomcat Server

Install Method 3 – Using External Tomcat Server

Falcon Deploy application can be deployed to servlet containers like JBoss, Tomcat, GlashFish and WebLogic. Here we show the steps to deploy to an external Tomcat Server.

Note

Please ensure you have completed the steps listed in the Pre-Install document.

Pre-Installation Checklist

The checks below are done as falcon user.

Ensure FALCON_HOMEORACLE_HOMELD_LIBRARY_PATHJAVA_HOME environment variables are set.

# Check that you are logged in as 'falcon' user
> id
uid=11777(falcon) gid=11777(deploy) groups=11777(deploy),10(wheel)

# Check FALCON_HOME is set.
> echo $FALCON_HOME
/falcon_deploy/app

# Check ORACLE_HOME is set.
echo $ORACLE_HOME
/u01/app/oracle/product/instantclient_12_2

# Check LD_LIBRARY_PATH is set.
echo $LD_LIBRARY_PATH
/u01/app/oracle/product/instantclient_12_2

# Check JAVA_HOME is set.
echo $JAVA_HOME
/usr/lib/jvm/jre

If FALCON_HOME does not return the above value, refer to pre-installation document to complete the setup.

Next, ensure sqlplus is in the path.

> sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Wed Oct 17 17:39:49 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Enter user-name:

If sqlplus is not working, check that you have completed the Oracle Client installation. If you have installed the Oracle full client it comes with sqlplus and is usually in the $ORACLE_HOME/bin directory. If you have installed the Oracle Instant Client, you have to download and install sqlplus separately. In this case, sqlplus can be in the root folder of $ORACLE_HOME.

Next, ensure java is in the path.

> java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

Install and run using External Tomcat Server

Download Apache Tomcat

Download the latest stable release of Apache Tomcat from https://tomcat.apache.org. In this example, we have used Apache Tomcat/8.5.34

Install Apache Tomcat

Copy the downloaded file to your server and install Tomcat to /opt.

> sudo tar -xvf apache-tomcat-8.5.34.tar -C /opt
apache-tomcat-8.5.34/conf/
apache-tomcat-8.5.34/conf/catalina.policy
apache-tomcat-8.5.34/conf/catalina.properties
apache-tomcat-8.5.34/conf/context.xml
...
...

Tomcat user and group

Create a new tomcat user and assign the user to tomcat and deploy group. We will disable login (recommended) for this user. Note, you need to assign the user to both operating system groups.

# Create the 'tomcat' group.                                            
> sudo groupadd tomcat

# Create the 'tomcat' user and add to groups 'tomcat' and 'deploy'
> sudo /usr/sbin/useradd -M -s /bin/nologin -g tomcat -G deploy tomcat

Tomcat Environment file

Create an environment file and the below environment variables. This will be useful whenever we manually start Tomcat.

> sudo vi /opt/apache-tomcat-8.5.34/bin/setenv.sh

ORACLE_HOME=/u01/app/oracle/product/instantclient_12_2
LD_LIBRARY_PATH=/u01/app/oracle/product/instantclient_12_2
JAVA_HOME=/usr/lib/jvm/jre
FALCON_HOME=/falcon_deploy/app
CATALINA_PID="$CATALINA_BASE/temp/tomcat.pid"

Update Permissions

Update permissions for the Tomcat installation directory.

# Set the owner and group to 'tomcat'                                         
> sudo chown -R tomcat:tomcat /opt/apache-tomcat-8.5.34

Tomcat Service

Create a file named tomcat.service in /etc/systemd/system directory. Here is an example configuration. The service can accept a wide variety of configuration. Refer to your operating system manual page for customizing your configuration.

[Unit]
Description=Apache Tomcat
After=syslog.target network.target

[Service]
Type=forking

User=tomcat
Group=deploy

Environment=ORACLE_HOME=/u01/app/oracle/product/instantclient_12_2
Environment=LD_LIBRARY_PATH=/u01/app/oracle/product/instantclient_12_2
Environment=FALCON_HOME=/falcon_deploy/app
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/apache-tomcat-8.5.34/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/apache-tomcat-8.5.34
Environment=CATALINA_BASE=/opt/apache-tomcat-8.5.34

Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
Environment='UMASK=007'

ExecStart=/opt/apache-tomcat-8.5.34/bin/startup.sh
ExecStop=/opt/apache-tomcat-8.5.34/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
Note

The environment variables ORACLE_HOME, LD_LIBRARY_PATH, FALCON_HOME, JAVA_HOME, CATALINA_HOME/CATALINA_BASE are required in systemd configuration even if you have them in the environment variable files like .bash_profile. If you omit the environment variables, the application may fail to start or deployments may fail with empty logs.

The options used above are explained here.

Note, umask is defined as environment variable and not as a systemd setting. This is required as newer Tomcat versions use environment variable to define this setting.

Notify systemd of new service file

After service is configured, we have to notify systemd of new service file. Execute the below command to complete the notification.

> sudo systemctl daemon-reload

Enable Autostart

Enable auto start on system boot.

> sudo systemctl enable tomcat.service

Start Tomcat Service

As falcon user, start the service and check the output for successful startup of the service.

# Start the service                                            
> sudo systemctl start tomcat.service

# Check the service status
> sudo systemctl status tomcat.service
● tomcat.service - Apache Tomcat
   Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-10-21 02:40:13 UTC; 4s ago
  Process: 12750 ExecStart=/opt/apache-tomcat-8.5.34/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 12758 (java)
   CGroup: /system.slice/tomcat.service
           └─12758 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/opt/apache-tomcat-8.5.34/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.Clas...

Oct 21 02:40:13 ip-10-0-1-248.ec2.internal systemd[1]: Starting Apache Tomcat...
Oct 21 02:40:13 ip-10-0-1-248.ec2.internal systemd[1]: Started Apache Tomcat.

Tomcat Home page

Open a browser and enter the address (server and port) where application is running. By default, Tomcat uses port 8080. The address is of the form hostname:8080 or ip_address:8080. You should get the default Apache Tomcat home page. Congratulations! You have successfully installed Tomcat.

Screen example: Tomcat home page

Tomcat Admin user

We will deploy falcon-deploy-<ver>.war using Tomcat Web Application Manager interface. Here we create the Tomcat admin user with roles manager-guiadmin-gui.

# Edit tomcat-users.xml file and add the content in <user> tag
> sudo vi /opt/apache-tomcat-8.5.34/conf/tomcat-users.xml

<tomcat-users>
    <user username="admin" password="secure-password" roles="manager-gui,admin-gui"/>
</tomcat-users>

Tomcat Manager remote access

By default, the Tomcat Web Application Manager is accessible only from a browser running on the same machine as Tomcat. Edit the context.xml file for manager application.

# Comment the <Valve> tag or edit the IP address to allow your IP                                        
> sudo vi /opt/apache-tomcat-8.5.34/webapps/manager/META-INF/context.xml

<Context antiResourceLocking="false" privileged="true" >
  <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>

For added security, use your ip address for exclusion.

Restart the Tomcat service.

> sudo systemctl restart tomcat.service

Tomcat Manager Home page

From the Apache Tomcat home page, click on the Manager App button on the top right corner. This should take you to the Tomcat Web Application Manager page. You can use the Manager application to stop/undeploy the default applications – Tomcat Documentation /docs, Servlet and JSP Examples /examples. Tomcat Host Manager Application /host-manager.

Multipart config

Out of box, Tomcat Manager allows files upto 50MB in size. Increase multipart-config to be able to deploy our WARfile.

# Edit web.xml to increase the max-file-size & max-request-size from 50MB to 200MB                                        
> sudo vi /opt/apache-tomcat-8.5.34/webapps/manager/WEB-INF/web.xml

    <multipart-config>
      <!-- 50MB to 200MB -->
      <max-file-size>209715200</max-file-size>
      <max-request-size>209715200</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

You are ready to deploy the falcon-deploy-<ver>.war

Deploy WAR and Test

Access the Manager application using the link http://<HOSTNAME/IP>:8080/manager/html. Look for the section titled Deploy. Use the option WAR file to deploy to upload the falcon-deploy-<ver>.war downloaded from https://f-d.io. Press the Deploy button to deploy to the server.

Screen example: Successful deployment of Falcon Deploy application

Validation

Open a web browser and enter the address – the server and port where application is running. Append the link with the context of the Falcon Deploy application. The resulting address should be something of the form http://<HOSTNAME/IP>:8080/falcon-deploy-<ver>.

If you are not sure, refer to the screenshot above. Under Applications, you will find the Path value. Click on the /falcon-deploy link.

This will launch the Falcon Deploy Installation and Configuration (Helper) application. If you see this screen, the installation is successful.

Congratulations! You have successfully installed Falcon Deploy application.

Post Install Step

Refer to the Post-Install document to complete the Falcon Deploy Installation and Configuration (Helper) Application. It is a mini web application bundled with Falcon Deploy application to help you complete the configurations with ease.

Updated on March 13, 2019

Related Articles