Shark for Java

Scanning an application in AWS Elastic Beanstalk (Tomcat + WAR File)

This document is for:
Invicti Enterprise On-Demand, Invicti Enterprise On-Premises

This guide shows you how to run a Java application in AWS Elastic Beanstalk and then use Invicti Shark to run an interactive application security testing (IAST) scan for that application.  

IMPORTANT: The following installation instructions are for the newer version of the Java IAST sensor. If you are running the older, aspectjweaver-based Java sensor, you need to remove the old sensor and any reference to aspectjweaver.jar from the JVM Options before proceeding with installing the newer version of the Java sensor.


  • Install Java.
  • Install Eclipse IDE for Enterprise Java and Web Developers.
  • Install Eclipse Extensions from "Web, XML, Java EE and OSGI Enterprise Development":
  • Eclipse Java EE Developer Tools
  • Eclipse Java Web Developer Tools
  • Eclipse Web Developer Tools
  • JST Server Adapters Extensions (Apache Tomcat)

Step 1: Prepare an example application using Eclipse IDE

  1. Go to File > New > Project.
  2. In the New Project wizard, search for and select the Dynamic Web Project option, then click Next. 

  1. Set the Project name field to axexample-java.
  2. Set the Target runtime field to Apache Tomcat v8.5.
  3. Set the Dynamic web module version field to 3.1.
  4. Set the Configuration field to Default Configuration for Apache Tomcat v8.5.
  5. Click Next.

  1. In the Java window, leave the default settings and click Next. 

  1. In the Web Module window, enable the Generate web.xml option and click Finish. 

  1. In the Open Associated Perspective? dialog, click No.

  1. Expand the axexample-java project.
  2. Right-click on the src folder.
  3. Select New > Other. 
  4. Highlight the Servlet option.
  5. Click Next. 

  1. Set the Java package field to com.mytest.axexample.
  2. Set the Class name field to axExampleJavaServlet.
  3. Click Finish. 

  1. Edit the contents of the file to read as follows:

package com.mytest.axexamplejava;



import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


 * Servlet implementation class HelloWorldServlet



public class axExampleJavaServlet extends HttpServlet {

        private static final long serialVersionUID = 1L;



     * @see HttpServlet#HttpServlet()


    public axExampleJavaServlet() {


        // TODO Auto-generated constructor stub



         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)


        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

                PrintWriter out = response.getWriter();

                out.print("<html><body><h1>Test JAVA Site Example for AWS Elastic Beanstalk</h1><br>Welcome to the main page.<br></body></html>");



         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)


        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

                // TODO Auto-generated method stub

                doGet(request, response);



  1. Expand the axexample-java project, right-click on the axexample-java/src/main/webapp folder, and select the New > File.
  2. Set the filename to index.html and click Finish.

  1. Edit the contents of the index.html file to read as follows:


<title>Test JAVA Site Example for AWS Elastic Beanstalk</title>



<h1>Test JAVA Site Example for AWS Elastic Beanstalk</h1><br/><br/>

<a href="axExampleJavaServlet">Click here to invoke servlet</a>



  1. Make sure that the changes to both new files are saved.
  2. Right-click on the axexample-java project, click on the Export… option, search for the WAR file option, and select it.
  3. Click Next and select a Destination for your exported WAR file.

  1. Ensure that the filename for your export file is ROOT.war.
  2. Click Finish. 

Step 2: Prepare Invicti Shark for Java

We will deploy the test application to the following URL: - you will need to change this to the hostname you will use for your test deployment.

  1. Create a new target website for the above URL, replacing with the URL for your chosen hostname. For further information, refer to How to add a website in Invicti Enterprise.
  2. Download Invicti Shark for Java from the Invicti UI and retain the Shark (IAST and SCA).jar file for the next step.

Step 3: Prepare a folder for your source code bundle

  1. Create a folder C:\axexample-java
  2. Create a folder C:\axexample-java\.ebextensions
  3. Copy your exported ROOT.war file into C:\axexample-java
  4. Copy your Shark (IAST and SCA).jar file into C:\axexample-java\.ebextensions
  5. Using a text editor, create a file C:\axexample-java\.ebextensions\invictishark.config
  6. Edit the contents of the C:\axexample-java\.ebextensions\invictishark.config file to read as follows:



    command: "mkdir -p /home/shark"



    JVM Options: '-javaagent:/home/shark/Shark (IAST and SCA).jar -Dacusensor.debug.log=ON'



    command: "cp .ebextensions/Shark (IAST and SCA).jar /home/shark/Shark (IAST and SCA).jar"


    command: "sudo chown -R root:root /home/shark"

NOTE: The parameter "-Dacusensor.debug.log=ON" is optional, and should ONLY be used for troubleshooting purposes. If this parameter is retained, this will output Invicti Shark logging as additional lines in the Tomcat logs starting with "[Shark-debug]".

  1. Use Windows Explorer to navigate to C:\axexample-java; press CTRL+A to select both .ebextensions and ROOT.war.
  2. Right-click on the selected items and click Send to > Compressed (zipped) folder.

  1. Rename your zip file to and retain your zip file for the deployment steps below.

Deploy your web application to AWS Elastic Beanstalk

  1. From your AWS Dashboard, navigate to Elastic Beanstalk > Environments.
  2. Select Create a new environment. 

  1. Set your environment tier to Web server environment, then click Select.

  1. Set the Application name field to the name of your web application. (In this example we used the name axexample-java).

  1. Set the Platform dropdown to Tomcat.

  1. Enable the Upload your code option and click Choose file. 

  1. Select your source code bundle for upload and click Create environment. AWS Elastic Beanstalk will now create your environment. This can take a few minutes.
  2. When the process is complete, you will be sent to your environment's dashboard.

  1. Take note of your environment's new URL which was created automatically by AWS Elastic Beanstalk:
  • You will need this to create a CNAME to point to this URL.
  • In this example, we would create a CNAME for to point to Here is an example using the Namecheap cPanel interface.

  1. Once the CNAME record has been added (giving time for DNS records to propagate), you can see the web application you have created by browsing to your URL (in this example

Test and scan your web application

Point your browser to your web application - in this example, - to confirm it is running as intended; you will get the following:

Finally, run a scan on your URL. The scan summary will confirm that Invicti Shark was detected and used for the scan.

Invicti Help Center

Our Support team is ready to provide you with technical help.

Go to Help Center This will redirect you to the ticketing system.