Compiling and deploying the project is just one click away from you, provided that you have added a WildFly application server to your list of Services. Simply right-click on your project and choose “Run”. A sequence of operations will be triggered:

1. At first WildFly application server will start

2. The Web application will be deployed

3. The index.xhtml page will be displayed

If you are not using NetBeans, simply follow the next section which will detail a generic compilation and deployment procedure that can be used from the shell prompt or wrapped by your Development Environment

Compiling and deploying from the shell

Any Maven project can be compiled and packaged by executing the following goals:

mvn clean install

This will generate an artifact named javaee7-mongodb.war which needs to be deployed on the application server.  The simplest way to do it, is copying the file into the standalone/deployments folder of WildFly.

If you want to automate the distribution of the Web application, we would suggest rather adding Maven’s WildFly plugin which will handle the deployment for you. In order to do that, you need to add the following plugin definition at the bottom of your pom.xml file:


 Now with the plugin in place, you can perform compilation, packaging and deployment with a single command:

mvn clean install wildfly:deploy

 A successful execution will terminate with an output like the following one:

INFO: JBoss Remoting version 4.0.3.Final
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.269 s
[INFO] Finished at: 2015-04-30T10:39:35+01:00
[INFO] Final Memory: 14M/37M
[INFO] ------------------------------------------------------------------------

Running the application

Whatever is your development environment, you will end up with the Web application deployed on WildFly. So now browse on over the following URL in order to test the application: http://localhost:8080/javaee7-mongodb/index.xhtml

Here is how your application should look like (We have omitted to include the stylesheets used in the index.xhtml page for the sake of brevity. You can find the complete source code of the book in the download area)

wildfly jboss mongodb java enterprise

You can try how the application works by clicking on the “Buy” button which will decrease the count of available book copies. Entering some text into the “Filter title” field and clicking on “Search” will restrict the search only to titles containing that text.

Java MongoDB

      MongoDB for Java Developers

  • A step-by-step tutorial to create leaner and faster applications using MongoDB
  • Reuse the skills you have acquired through Hibernate or Spring to promote your applications to use NoSQL storage
  • Explore the list of libraries that are already available to assist you in developing Java EE applications with MongoDB