Category: Code

How to access the ExtraHop REST API using Java

Although ExtraHop provides a powerful visualization system out of the box for viewing and analyzing your network traffic, you may need to retrieve your ExtraHop network data for integration into other systems. Perhaps you need device data for an overarching inventory management system. Or you may need specific application metrics for custom calculations involving other data sources. ExtraHop provides an extensive REST API for these purposes. It provides access to just about anything that you would want to know about your network. If you are looking to export a large amount of your network data in real-time, then you may want to opt for our Open Data Stream.


How We Log Exceptions in Production Java Application Servers

One of the challenges of Java web application server development is catching and analyzing exceptions from your web application after deployment into a production environment. Whether your web application is deployed on Tomcat, Apache Geronimo, Glassfish or JBoss/Wildfly, analyzing exceptions involves digging through application server logs to isolate an issue.


Creating Tables Programmatically with DynamoDB Local

For testing with a large number of tables, deleting and recreating tables manually in the AWS Explorer pane in Eclipse can be tedious. It easy enough to create a simple utility class to delete and recreate your tables. Your AWS Explorer immediately updates with results. This can easily be extended to populate with data, too.

Setting Up a Spring MVC with AWS Project in Eclipse

Create the Spring MVC + AWS Project

I am running Eclipse Luna and added both the Spring Tool Suite (STS) and AWS plugins. I used the project wizard to first create a Spring MVC project.

Screen Shot 2015-03-19 at 2.46.43 PM

With the project created you will get your MVC dispatch servlet configured and even a basic home controller.

Now onto AWS. In your project properties, add the AWS SDK for Java library to your build path.

Screen Shot 2015-03-19 at 2.48.04 PM

Set up the Local DynamoDB Server

I am using DynamoDB, so let’s get a local DynamoDB server set up.

Install the DynamoDB Local Test Tool under Eclipse Preferences.

Screen Shot 2015-03-19 at 2.33.23 PM

In the AWS explorer, set your region to local.

Screen Shot 2015-03-19 at 3.06.07 PM

Now let’s see if it runs.

Screen Shot 2015-03-19 at 3.09.38 PM

Set up the Local Tomcat Server with AWS Libraries

Great. Now let’s get a local tomcat server set up for testing locally. We will need to add the AWS SDK libraries to the Tomcat classpath via

 Create the First Domain Objects

Now let’s set up our first domain objects to persist to the local DynamoDB server. I’ll create an abstract User class and a EndUser child class using the DynamoDB Java annotations. There isn’t much here in the classes for now, but let’s just store username and password to get started.


 Create the Table in the DynamoDB Server

Now create the table in the DynamoDB server. You only need to specify the primary key.

Screen Shot 2015-03-20 at 12.50.13 PM

Screen Shot 2015-03-20 at 12.54.08 PM

The table should now show up in the AWS explorer.

Screen Shot 2015-03-20 at 12.54.27 PM

Let’s use the default Spring home controller to test saving an EndUser since it is already set up to be the default launcher. Make sure to set your AmazonDynamoDBClient to use your local server.

Persist Data to the DynamoDB Server


Now we are ready to run it! Select Run on Server and choose your Tomcat Server (that was configured with AWS above).

Screen Shot 2015-03-20 at 9.45.11 AM

And you should get the default Spring MVC home page.

Screen Shot 2015-03-20 at 12.55.48 PM

But that doesn’t show us if the user was created in the DynamoDB. To verify that, double click the User table in the AWS explorer. You should see the new entry in the User table. That’s it!

Screen Shot 2015-03-20 at 12.56.05 PM

An Amazon Web Services Mobile, Web and Cloud Project

Starting a new project that will involve developing a mobile, web, and cloud solution for a mapping application. Mobile will include Android and IOS. Simple image processing to resize uploaded images will also be required. Users must be able to synchronize data across all platforms. I’ll be using Spring MVC and Spring Security on the web side. I have not decided if or what template or web UI library I’ll use. That is something I can decide later. Near term I need to decide which PaaS solution to use: Amazon Web Services (AWS) or Google Cloud Platform (GCP). I used Google App Engine a few years ago for a GWT and Android cloud application. I would like to use AWS to get that knowledge and experience. And AWS still appears to be the most popular cloud platform, so it is good to have it on the resume.

The following is a comparison of what my project requires and what is provided by AWS and GCP.

  • I will be developing in Java using Spring MVC and Spring Security. Both platforms support Java and these frameworks.
  • Both provide a NoSQL database solution.
  • I prefer to use a JDO or JPA persistence solution for flexibility. I like the idea of my code being portable. GCP supports JDO and JPA. AWS has their own Java Object Persistence Model. It appears to be similar to a JDO/JPA solution – just using their own annotations. The paradigm is the same, so probably not a big deal.
  • For running database queries, again AWS provides their own solution – less portable. GCP supports JDO and JPA queries as well as their own Datastore Queries. In my experience with GCP, larger and more complicated queries required using the GCP Datastore Queries.
  • Surprisingly, AWS does not have an image processing service. Third party services that work with AWS (like are available or you can spin your own. GCP provides an image processing service that supports resizing, cropping, etc.
  • For data storage (images), both platforms provide comparable services, Amazon S3 and Google Cloud Storage.
  • My application will provide a search feature. Both platforms provide a search service. Amazon has Cloud Search while Google has a Search API.
  • Critical to my application is integration with mobile. Both platforms provide Android and IOS mobile cloud APIs. AWS lists various services such as analytics, database, S3 storage, and event streaming while Google has Cloud Endpoints.  Here it appears that Google is lacking. Rather than provide access to specific services, Cloud Endpoints builds a client library to your API. So I am required to develop an API to my database and Cloud Endpoints builds the client library. That is more work.
  • Also critical is synchronizing data across all devices. In the ideal case, I could use the same persistence model across all devices. I have experience with this on my previous Google App Engine project and it is not easy maintaining data integrity between multiple devices and the cloud. AWS provides the DynamoDB Object Mapping for Android and IOS which is similar if not the same as the Java Object Persistence Model discussed above. Can I define a single POJO domain package to be used for the cloud, Android, and IOS? That would be great. GCP doesn’t provide anything like this. The closest that I can find is Cloud Sync which seems to be focused on lightweight user preferences and game data.

The last two bullets pushes me to use AWS.