Getting Atmosphere – framework for Comet style communication – up and a first sample running on Tomcat

Over the past weeks, I have been dabbling in Comet style, push-based, asynchronous communication enabling frameworks and libraries – including CometD, Atmosphere, Kaazing, jWebSocket, Grizzly and others. This short article will describe how I went about setting up Atmosphere on my local environment to the point that I could successfully run at least one of the samples shipped with Atmosphere – and had the sample loaded in NetBeans for inspection and further development.

The article presumes some knowledge of Git and requires Git to have been installed. See my earlier article (https://technology.amis.nl/blog/14676/preparing-your-environment-for-modern-open-source-java-libraries-and-frameworks-using-git-and-maven-throwing-in-tomcat-as-a-bonus) for details on what I did to get Git going as well as have Maven configured. I also described how to set up NetBeans (https://technology.amis.nl/blog/14661/first-experiences-and-getting-started-with-glassfish-3-1-and-netbeans-7-x-its-a-breeze) and Tomcat 7 (https://technology.amis.nl/blog/14688/installing-tomcat-7-and-configuring-as-server-in-netbeans).

Atmosphere currently has its home on GitHub: https://github.com/Atmosphere/atmosphere. This where the sources are, both for the framework itself as well as for the samples demonstrating some its capabilities.

To get going locally, I cloned this repository from GitHub to my local Git environment. Here are the steps:

Run Git GUI:

Image

Click on Clone Existing Repository

Image

Set the source location – the GitHub URL for Atmosphere. Specify the local directory (not yet existing) into which the repository should be cloned.

Image

Click on the Clone button.

At this point, source are going to be downloaded from GitHub and copied to the local file system. This will take some time.

When cloning is done, the file system will look like this:

Image

The Git Repository contains the sources for Atmosphere and its samples. It also has pom.xml files that allow build of [components of] the framework.

Let turn our attention to the TicTacToe sample.

Image

Open the command line and set focus to the TicTacToe directory. Run Maven with the clean install target:

Image

Maven will go and build the tictactoe sample. In order to do so, it will download many dependent objects to the local Maven repository:

Image

After some dozens of seconds, Maven will complete:

Image

The WAR file has been built:

Image

and is ready for deployment on Tomcat.

Open the Tomcat Administration console in a browser window and click the browse button to select a WAR file to deploy:

Image

Select the WAR file that was just built by Maven:

Image

and click the Deploy button.

After a little while, the application is deployed and shows up in the list of applications.

Image

Click on the link for atmosphere-tictactoe application to bring it up:

Image

and open a second window with the same URL – as the game of TicTacToe should be played from two clients in order to see the push effect:

Image