Imagine a bacon-wrapped Ferrari. Still not better than our free technical reports.
See all our reports

The Great Java Application Server Debate: GlassFish

Update: Since this post was published, RebelLabs has completed the full version of The Great Java Application Server Debate with Tomcat, JBoss, GlassFish, Jetty and Liberty Profile. Feel free to check it out!

Download the full PDF report from RebelLabs

***

This blog post continues the Great Application Server Debate series, in which we have already covered IBM Liberty Profile, Jetty, Tomcat and JBoss. Today we’re talking about GlassFish. As with previous posts, we will be reviewing the application server purely from a developers point of view.

GlassFish is the reference implementation for Java EE, originally developed by Sun Microsystems, and now owned by Oracle.

GlassFish logo

Introduction

Aaah good ol’ GlassFish! So, what does it look like and how do I use it? These were the questions that came into my mind when I first heard about it. I think the first time when I got a chance to install it and try it out was back in 2008. During that time I was developing quite a small and simple web application and I was kind of freaked out when I got the server up and running. I still remember some jokes with GirlFriends and GlassFishes.

Why was I freaked out? Because it looked so big and enterprisey. It had a nice big web-based management console, asadmin and what not.

So, what makes GlassFish so special? I think the most special thing is that it is developed by Oracle, so it comes from the home of Java – our bread and butter.


Read the complete Java Application Server Report where we discuss the pros and cons of App servers such as: Tomcat, Jetty, GlassFish, IBM WAS Liberty Profile and JBoss (aka WildFly):


Go and get it!

GlassFish can be downloaded from http://glassfish.java.net and there are two options available: GlassFish Open Source Edition and Oracle GlassFish Server. What’s the difference? Oracle says that the Oracle GlassFish Server is the world’s first implementation of the Java Platform, Enterprise Edition (Java EE) 6 specification. The GlassFish Open Source Edition is as well, but it doesn’t come with all the same features as well as having the “somebody to blame”-s from Oracle when things go wrong.

Oracle GlassFish Server comes with many tools and features that are not bundled with the open source edition. These features are mostly for better management, better scaling and better centralization. Oracle also tries to convert their non-paying customers into paying customers providing quick fixes and hot patches for commercial users. With that being said – is the open source version a very risky and buggy piece of software? It’s actually not, but if you need guarantees, quick fixes and somebody to fulfill a promise, then it’s a good bet! With a little fee of course :)

I grabbed the GlassFish Server Open Source Edition installation package from here. Surprisingly, the package was not so big, only 53 MBs in size! Back in the day, it was definitely a bit bigger.

Start, run and stop

During the time when writing this article, there was version 3.1.2 available and I downloaded it. GlassFish’s installation package is quite handy, as it comes in a self-extractable archive. The only thing I had to do is run a large .sh “script” and GlassFish was in place. Surprisingly I also found some .exe files from the installation directory although I downloaded the version for *nix. If you don’t like the idea of an installer, you can also choose the unzip install option which comes in a 30 MB larger download.

When looking into the “bin” folder, there were no startup scripts. So how do you start GlassFish? Actually they provide a megatool called “asadmin” that can perform various administrative tasks from starting the server to deploying an application. Basically, you can do everything with it, other than get it to make the coffee. It’s a shell environment with commands and features. Some people hate it, some love it, I actually quite like it once I got used to it, although the beauty with regular startup or management scripts is that their intended behaviour is typically stated by the script name, however, asadmin hides everything from you. Realistically, you need to read some docs to get yourself going – Whaaaaat, I need to read docs to be able to start my server? Bah. Unlike Jetty or Tomcat, it’s not as straightforward to get GlassFish up and running. You can guess some commands or look into docs. I chose the latter.

sigmar$ ./asadmin
Use "exit" to exit and "help" for online help.

When I entered to asadmin, I typed in “start-domain”, as seen above, and I saw a response that indicated that the server should be up and running:

asadmin> start-domain
Waiting for domain1 to start ....
Successfully started the domain : domain1
domain  Location: /Users/sigmar/Downloads/glassfish3/glassfish/domains/domain1
Log File: /Users/sigmar/Downloads/glassfish3/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

Deployment of the application can be done also using our old buddy asadmin. You can either run the command directly (start asadmin shell and use the “deploy” command) or use the web interface, that can be reached at http://hostname:4848, now the server has started:

asadmin> deploy /Users/sigmar/DemoMaterials/lr-demo-ver1.war
Application deployed with name lr-demo-ver1.
Command deploy executed successfully.

To stop the domain, I executed a similar command:

asadmin> stop-domain
Waiting for the domain to stop ...
Command stop-domain executed successfully.

Welcome to the world of enterprise software. Phew, it can be a scary place!

What’s inside the toolbox?

The toolbox includes the following:

  • Administration Console (web based UI);
  • asadmin utility (command line interface);
  • REST interfaces;
  • Update Tool;
  • keytool utility.

Basically everything that is needed to manage and maintain a GlassFish server is put into the asadmin utility. It is even possible to manage remote servers with it, which is cool!

One thing that I like about asadmin is scripting. Yeah – it is possible to write various asadmin scripts for managing your deployments and servers. These scripts can be executed inside asadmin as if you are running regular shell scripts.

Lets manage!

GlassFish provides two ways to administer your server or server cluster. You can either use the asadmin utility or it’s web-based admin console, that can be reached at port 4848 by default.

And now we come to our appserver simplicity test. In every article we try to describe, how easy it is to modify some server configuration, so this time we’ll modify the HTTP port value.

GlassFish uses network listeners for it’s connections with the outside world and thus, also HTTP connections are handled by network listeners called http-listener. The easiest way to modify the HTTP port is through the Web-based admin console:

Screen Shot 2013-05-07 at 7.37.38 PM

Wow, that was easy! Despite it being big and enterprisey, the GlassFish server has a highly modular architecture enabling you to configure it mostly (I think there are some cases where you need to restart the whole system) without restarts! I saved the new HTTP port value and now I had my new HTTP port working.

It is possible to create different configurations and apply them on different servers or server clusters. I’d say that this has been done in a very DevOps friendly way.

For those who are still real fans of XML files, it is possible to configure everything in the domain.xml file too:

<network-listeners>
  <network-listener port="8800" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
  <network-listener port="${HTTP_SSL_LISTENER_PORT}" protocol="http-listener-2" transport="tcp" name="http-listener-2" thread-pool="http-thread-pool"></network-listener>
  <network-listener port="${ASADMIN_LISTENER_PORT}" protocol="pu-protocol" transport="tcp" name="admin-listener" thread-pool="http-thread-pool"></network-listener>
</network-listeners>

Community, docs and support

I haven’t used and managed GlassFish myself but I must admit that crawling through the docs, forums and mailing list made me feel secure. The forum is quite active, there are many mailing lists specializing on different parts and areas of GlassFish and the documentation looks pretty good.

Summary

I think that GlassFish is an interesting piece of software that can be considered as an application server when planning to host some bigger-scale application. It has well-developed scalability and management features, large and active community and also possibility to move on to the commercial version to get official support and more advanced management tools from Oracle.

It’s modular architecture enables to configure it extensively and you can restart it’s components without restarting the whole server. GlassFish has full Java EE 6 support and it tries to be as standardized as possible.

It looks very big but is actually relatively small – the installation package is around 53 megabytes in size. DevOps guys will probably love it when they see Glassfish’s Administration Console (you can click around and imagine yourself being an airplane pilot).

  • John Clingan

    Sigmar, thank you for the writeup. As the product manager for GlassFish, this provides valuable insight for how a “new user” perceives GlassFish. While you mention “Enterprise-y” quite a bit, we also want to make GlassFish as “approachable” as possible for new users. Your point about having a “startup” and “shutdown” script is well taken. We’ll consider it for a future release of GlassFish. It’s a bit too late for GlassFish 4.0, but we’ll look into it in subsequent releases.

  • https://blogs.oracle.com/reza/ Reza Rahman

    Thanks a lot for the write up and the kind words!

  • http://twitter.com/henk53 henk

    I don’t consider GlassFish enterprisy, but one complaint I occasionally hear is that you can’t clean GlassFish’ deployments by simply deleting stuff from some directory. You have to run it through asadmin, which might start up stuff before it cleans.

    This is extra painful in Eclipse. The Oracle tooling starts up GlassFish when you do a server -> clean, but if the deployment is problematic you’ll have to sit through a whole slew of error messages and delays first. Then there’s no choice for whether that startup needed for cleaning is debug mode or normal mode (it’s normal), so if you actually wanted debug you have to shut-down the server after cleaning and then starting it up again in debug.

    Just deleting stuff from a directory would just be so much more easier and simpler. If Tomcat, Jetty and JBoss can do it, maybe GlassFish can do it to?

  • https://blogs.oracle.com/reza/ Reza Rahman

    Please consider filing a feature request: https://java.net/jira/browse/GLASSFISH.

  • Sigmar Muuga

    Thanks guys! If you feel that something important or notable as left out from the post, please feel free to mention these here in the comments section! :)

  • kingkoduru

    Nice write up. I will try some fish now.