Getting started with Glassfish using Maven

In this post I detail simple instructions for installing Glassfish v3 onto Ubuntu (although it will work just as well with Redhat, debian, and anything else). I also show how to create and deploy a simple WAR using Maven.

Installing software

Start by checking that the correct packages are installed – for distro’s other than Ubuntu you will need to modify this command:

Download glassfish into your opt directory. Get the non-platform specific ZIP file. uncompress the zip within your /opt/ directory, which should then decompress to /opt/glassfishv3

Start the glassfish application server like this:

After that, you can access the glassfish control panel by going to: http://www.your-server.com:4848/

Creating your Java Project

To create a project, use maven as shown below. For more info on using maven, have a look at my previous posts, Getting started with Maven and Spring and Hibernate Tutorial part 4 – annotations and maven. Running just the below command will generate a ‘hello world’ JSP example, that will work for this example without modification.

Modify your pom.xml along the lines of the below. This will allow the use of the glassfish plugin which is from https://maven-glassfish-plugin.dev.java.net/.

Building and deploying

The following commands are reasonably self describing – glassfish:deploy will deploy a WAR, and glassfish:redeploy will redeploy it – as trying to deploy over an existing application will fail.

You can then access your application by going to http://www.your-server.com:8080/hello-world/

4 thoughts on “Getting started with Glassfish using Maven”

Leave a Reply

Your email address will not be published. Required fields are marked *