Run a MongoDB data adapter for Atom Hopper with Netbeans

Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to use the new MongoDB data adapter.

After testing, refactoring etc. is complete. E. For the MongoDB data adapter, it is likely to be enabled by default, not in the current Hibernate data adapter.
Important note: Be sure to put Index in DateLastUpdated — this will significantly improve HTTP GET requests.

As stated in our wiki, there are several ways to run Atom Hopper. To test a MongoDB adapter with Atom Hopper, let’s consider how to run it from Netbeans 7.1. You will also need a MongoDB running locally on your computer.


The source code is open source under an Apache 2 license. You can use Git to easily get the source code. I am on OS X and I tend to use GitHub’s Mac client, but you can also use Git functionality in Netbeans.


Once you have downloaded the main repository for Atom Hopper, you can use Netbeans 7.1 to download the project. Run Netbeans, if it is not already running, and select: “File” -> “Open Project”, find the Atom-Hopper folder, click “Open required projects” and click “Open”.

After loading a project, right-click the ATOM Hopper — ATOMpub Server Collection project and select “Clean up and build”.


At this stage, the project should have been successfully built — and it may take some time as all dependencies should be loaded first. Usually, when you run Atom Hopper, you use the resulting WAR file and embed it into something like Apache Tomcat. For simplicity and because it’s only for testing the new MongoDB adapter for Atom Hopper, I’ll just show you how to run the standalone version of Jetty used to debug Atom Hopper.

Right-click the default ATOM Hopper project — Jetty Server and select Properties.

In the opened dialog box “Project Properties” click “Run” in the left part of the categories, and then add the word “start” to the text field “Arguments” on the right.

Click the Ok button and return to the project. Go to the ATOM Hopper — Default Jetty Server project files and find the file atom-server.cfg.xml and application-context.xml.

Let’s add MongoDB as the default adapter to the application-context.xml file. This is done by commenting on the Hibernate adapter and commenting on the MongoDB adapter. The file should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<!-- MongoDB -->
<mongo:mongo host="localhost" port="27017"/>

<bean name="mongoTemplate" class="">
<constructor-arg ref="mongo"/>
<constructor-arg name="databaseName" value="atomhopper"/>

<bean name="mongodb-feed-publisher" class="org.atomhopper.mongodb.adapter.MongodbFeedPublisher">
<property name="mongoTemplate" ref="mongoTemplate" />

<bean name="mongodb-feed-source" class="org.atomhopper.mongodb.adapter.MongodbFeedSource">
<property name="mongoTemplate" ref="mongoTemplate" />

Now we just need to install the atom-server.cfg.xml file so that it points to the publisher and MongoDB news source:

<?xml version="1.0" encoding="UTF-8"?>

<atom-hopper-config xmlns="" xmlns:xsi="" xsi:schemaLocation=" ./.../config/atom-hopper-config.xsd">
<author name="Atom Hopper" />

<host domain="localhost:8080" />

<workspace title="Testing Namespace" resource="/namespace/">
<categories-descriptor reference="workspace-categories-descriptor" />

<feed title="Testing Feed" resource="/feed">
<publisher reference="mongodb-feed-publisher" />
<feed-source reference="mongodb-feed-source" />

Continue and recompile the default ATOM Hopper — Jetty Server project, then right-click it and select “Run”.

The startup command we installed earlier allows the Jetty server to start at the following default values:
http:// localhost: 8080 / namespace / feed /

Use the above URL to check everything. You can execute HTTP POST or GET for the channel. Here is an example of ATOM XML code that you can use for testing:

<entry xmlns="">
<title type="text">This is the title</title>.
<name>John Doe</name>
<content type="text">Hello World</content>
<category term="MyCategory 1" />
<category term="MyCategory 2" />
<category term="MyCategory 3" />

Note. You can use a plugin such as XHR Poster for Chrome to easily place it in the Atom Hopper, or a plugin such as Poster for Firefox.

Before running HTTP POST, make sure that the content type is set to application/atom+xml. You can get more information on how to use the plugin to test Atom Hopper, from here.

To terminate a standalone Jetty Server, simply return to the ATOM Hopper — Jetty Server default project, then right-click it and select “Properties”. In the Project Properties dialog box that opens, click “Run” in the left part of the categories and then add the word “stop” to the text field “Arguments” on the right. Then run the ATOM Hopper — Jetty Server project by default, which will send the command to finish the work to the running instance.