Skip to content
Mihir Kakrambe edited this page May 12, 2016 · 35 revisions

Welcome to the PacketAnalyzer wiki!

This page serves as a landing page for the wiki and provides information about how to build and deploy the application. For more information about the components of this application, please check other wiki pages.

Build

This is a Maven application and hence can be built with maven. Make sure you have Maven installed on you system.

Command line

From the root directory of the application (where pom.xml file is present) type the following command in your terminal -

mvn package

For the very first time, it can take a few minutes where it has to download the transitive cover of the dependencies mentioned in pom.xml file. Subsequent builds should be faster.

You can even make a clean build in subsequent times by following command -

mvn clean package

Make sure you have Maven-clean plugin installed.

IDE Plugins

If you are using any IDE like Eclipse then make sure you have the Maven Plugin installed (e.g. Eclipse-Maven-Plugin).

Deploy

Installation

Tomcat7 is used as a container for loading servlets for this application. To install tomcat7 via Apt package manager run the following command in your terminal -

sudo apt-get install tomcat7 tomcat7-admin tomcat7-common

This will install tomcat7 as a service which can be started with -

sudo service tomcat7 start

Pre-Deployment Steps

Before you can deploy the war file for this application on Tomcat, you have to configure Tomcat correctly. To do so please follow the guide below.

Directory Structure

  • CATALINA_HOME - By default, this environmental variable will be set to point to the /usr/share/tomcat7/ directory. This directory contains the bin folder among other folders which holds all the tomcat related scripts, most important of which is catalina.sh script. This scripts starts Tomcat and runs applications within it.

  • CATALINA_BASE - Although there is no default value for this environmental variable, it should point to the directory which contains folders like conf, webapps, logs, server etc. If you have installed Tomcat via apt-get then you can find these folders in /var/lib/tomcat7 directory.

Roles and User Credentials

To access manager webapp through browser or deploy applications with command line tools, one has to define appropriate manager-roles in the tomcat-users.xml file present in $CATALINA_BASE/conf/ directory. Some example roles and user credentials are mentioned below -

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-gui" /> 
<user username="adminscript" password="adminscript" roles="manager-script" />

Now one can deploy application war files through either text/command line interface or Manager web-app. For this particular application, only one more step of configuring elasticsearch server is remaining before you can deploy it on Tomcat server. Check out the next section for it.

Elasticsearch Properties Configuration

Spring servlet starts an integrated Elasticsearch server instance at the time of application loading. Elasticsearch server is being configured (as of now) by reading its configuration properties from elasticsearch.properties file. Elasticsearch needs two directories for storing data and logs respectively. Paths to those directories are specified in elasticsearch.path.data and elasticsearch.path.logs properties. Currently they point to a tmp directory where everyone has write access. But you should change the path to point to appropriate directory where only system user "tomcat7" has write permissions. Make the appropriate changes and save the file.

Once properties are configured, rebuild the project with Maven. Now the application is ready to be deployed on Tomcat.

Deployment

WAR file deployment on Tomcat can be achieved in two ways -

Command line - Curl

curl --upload-file /path/to/war/file/protocolanalyzer-1.0-SNAPSHOT.war "http://adminscript:adminscript@localhost:8080/manager/text/deploy?path=/protocolanalyzer&update=true"

where /path/to/war/file should be replaced appropriately. Be careful to provide appropriate user credentials for the role of manager-script.

Manager Webapp

Open manager webapp from browser by hitting following URL -

http://localhost:8080/manager/

(You will have to provide appropriate user credentials saved in tomcat-users.xml file for the role of manager-gui)

In the manger webapp you can specify the context path (e.g. /protocolanalyzer) and upload a WAR file to be deployed.

After a successful deployment, the application can be accessed on following URL -

http://localhost:8080/protocolanalyzer/

Debugging and Status Checking

If all the steps mentioned above are carefully followed then the deployment should succeed. However in case of any failures or errors one can look at the log files present in -

/var/lib/tomcat7/logs/

directory. Server-wide logs are stored in catalina.<DATE>.log file. Host-wide (e.g. localhost applications) logs are stored in localhost.<DATE>.log file. One or the other log file will lead you to the root cause of the error.

Clone this wiki locally