Over a million developers have joined DZone.
Platinum Partner

Java EE Continuous Integration Powered by Maven & Glassfish

· Java Zone

The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.

Can you compile, deploy and test your Java EE projects with just 1 line of command? Check it out.

I have no time for documentations lately, but I prefer to give you a chance to early adopt my build script and take your own conclusions. Following the steps below, you will have my Java EE 5 application running in your Glassfish v2.1 server - including test data populated in the MySql database.

What the script do is:

  1. Compile, do unit tests and pack the Arena-PUJ Project.
  2. Deploy the RESTful web-service. (*.ear)
  3. Populate the MySql with the test data.
  4. Execute the integration tests
  5. Deploy the DWR web application (*.war)

The magic is done by a set of of Glassfish's ASADMIN commands powered by Shell Script and the Maven AntRun Plugin. You can checkout the project with all artifacts and ask me if you have any suggestion or doubts. Have fun :)

Important: the current version of the script only works on UNIX-like machines because it uses Shell Scripts. I created and tested the script on the Ubuntu OS and I didn't have interest time to translate it for a DOS script (*.bat). So if you are using Windows, sorry but your blog reading finishes here. If you are a Windows user and you would like to contribue with a BAT file, please send that to me and you will receive the proper credits - it may be a good contribution to my pet project.


No, you can't skip these non pleasant steps, but at least you need to do it just once.

Check if you have all software you need:

  1. Java 6.x
  2. Maven 2.x
  3. MySql 5.x
  4. Mercurial
  5. Glassfish v2.1 * the ones living in the future can try the latest v3 b66 and please do contribute with the FishCat if you find a bug.

After installing everything, startup the database and the application server. Open a terminal and type:

	sudo service mysql start
asadmin start-server

* By default MySql will be already running as service, so you probably can skip the first step.

Creating the passwords file and the arena database

For portability and obvious security reason, I couldn't type the password direct on the script, so I let the users to use their own local passwords. Due to that reason you have one more boring step to proceed: to create a passwords file and save it as ~/.passwords, containing the following property values:


Known limitations: the current Java code of Arena-PUJ only works for IMAP secure SMTP servers. I plan to review the code making it more generic, but for now it is guarantee to work only with a GMail-like SMTP server. I couldn't find an elegant way of using the AntRun plugin with the Shell Script, so I hard coded the ~/.passwords in the script. Despite that, if you invoke it by line command, you can pass an argument with the name of the passwords file - I just couldn't get it working smoothly with the Maven plugin :(. The project should work with other databases, since I am not using any MySql specific trick in the domain model - but I never tried and I can't guarantee if it will really be portable for other DBs. You need at least to update the deployment descriptors if you plan to test it on other Java EE Servers and the persistence.xml if you will use other Database - and please tell my if you want to try it, I am very interested about the results.

Building and deploying

After installing the software and creating your configuration file, the good news: your job is done, now it is time for my magic script to show its strengths. Open a terminal and type the following commands:

Updated: please check the new instructions here.

Now you take a coffe, watch the screen and smile - it is time to see why Glassfish is my preferred Application Server :)

Successful build? just access http://localhost:8080/arena-dwr/

Integrating with Hudson

The built system presented here is a pure Maven Script so it is piece of cake to create a Hudson job to run the script. You can see here the build history of the Arena-PUJ.


If you know me you know how I hate manual configuration steps and other traps the big commercial projects impose in our lives. To make my own and small project clean and easy is the minimum my slim ego requires to continue with me - but I have just few spare hours a week to push this pet project to a higher level so I appreciate any enhancements and suggestions you can bring to me. It is a new project and I am pretty sure it will get much better in the near future. All commands in the build script can be done through the Glassfish Administration Console - it contains no magic secrets actually.


This beautiful piece of configuration was made better due to the tips and discussions in the Brazilian Java Community and always with the friendly support from the Glassfish's team. My best thanks for all of you and a special kudo to Márcio Correia from CEJUG.

From http://weblogs.java.net/blog/felipegaucho

The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}