Monday, 7 May 2012

From Tomcat to GlassFish (part I) - Getting Started


I've been using Apache Tomcat for some time now and it has done me well. I work for a small company that develop and deploy Java Web Applications and I was tasked with finding and deploying an enterprise grade server for our applications and so I've gone with Oracles GlassFish sever.

Tomcat is a Servlet/JSP container that you can configure and do allot with but GlassFish does so much more out of the box. GlassFish has allot more Administration tools and is supported by Oracle, it also has it's own HTTP front end called Grizzly.

To get Started download the latest version of GlassFish from here. You have the option of the Open Source edition or the Oracle server. For this purpose we are using the Open Source Edition.



Once Downloaded you should have a glassfish-.zip file. Extract this anywhere on your system that you like (/opt/glassfish is a sugestion) and open up a terminal and cd to that directory. In this expanded Directory you will see the following

  • Bin - binary files including asadmin
  • glassfish - includes further directories for the container(s)
  • javadb - Java Database (optional use not discussed here)u
  • mq - Message Queue (not discussed here)
  • pkg - package directory used for updating and extending GlassFish

Before we start make sure you have a JRE or JDK installed on your system. You can download the latest version from Oracle http://www.oracle.com/technetwork/java/javase/downloads/index.html
If like me you have multiple java versions on your system such as Oracle's JDK and OpenJDK you might want to specify exactly what one you want GlassFish to use. You can do this by adding this line to the file /glassfish/config/asenv.conf
AS_JAVA="/usr/PATH TO your JDK or JRE"
You can use any text editor to do this such as vi.

In the bin directory you will find asadmin, you use this to administrate GlassFish via the command line. Add asadmin to your path or cd to the bin directory and type ./asadmin help for more information on what you can do.

By default GlassFish comes with a domain already set up (domain1), you can see this in /glassfish/domains , you can also view domains by entering asadmin list-domians.
Lets remove this default domain and create a new one............
# asadmin delete-domain domain1
# asadmin create-domain example
You will then be asked to give an administrator name and password or you can press enter to accept default user admin with no password (for obvious reasons doing this will leave your GlassFish insucure).


As you will see GlassFish goes ahead and uses some default port numbers. Default port numbers are....

4848 Admin port
8080 HTTP Instance port
7676 JMS port
3700 IIOP port
8181 HTTP_SSL port
3820 IIOP_SSL port
3920 IIOP_MUTUALAUTH port
8686 JMX_ADMIN port

You can change these in the Admin Console (Will be covered later) or by editing the file /glassfish/domains//config/domain.xml , this file is the equivilant to Tomcats server.xml file. You can also change ports by issuing commands like so........

  1. To change the HTTP port to 10080:

    asadmin set server.http-service.http-listener.http-listener-1.port=10080
  2. To change the HTTPS port to 10443:

    asadmin set server.http-service.http-listener.http-listener-2.port=10443
  3. To change the administration server port to 14848:

    asadmin set server.http-service.http-listener.admin-listener.port=14848 
If you have a port range in mind you can change the port numbers on creating a new domain. This is also very handy if you are creating multiple domains. When creating a new domain you can pass the argument portbase with the portbase number of your choice and it will increment the portnumbers to that number like so.......
Admin port: portbase + 48
HTTP listener port: portbase + 80
IIOP listener port: portbase + 37
JMX port: portbase + 86

Lets say you have decided on a portbase of 2000 you would type......
# asadmin create-domain mydomain --portbase 2000
and GlassFish will give you a new domain "mydomian" with HTTP port 2048, SSL port of 2081 etc. this can save you time and instantly resolves port conflicts if you are creating multiple domains.

Now that you have done all the set up it's time to run it up and try it out. You can monitor the log as you start it up by tailing the /glassfish/domain//logs/server.log file. Issue the command asadmin start-domain so in this case asadmin start-domain example.


Now you can open up your web browser and enter localhost:8080 you should be presented with the following page. 


Congratulations you have successfully set up your GlassFish server. Next time we'll look at further configurations, using the admin console, security and web applications. Stay Tuned.


Monday, 23 November 2009

Another Linux convert

I was down in Dundee at the weekend visiting a friend and knowing my interest in Linux she asked me about it, her first question being "How much does it cost". When I told her it was free she was very impressed and asked if I could install it on her computer. She had a very dated looking Windows XP set-up (I'm not sure it even had SP2 installed) and her major gripe was the fact that she couldn't install the new live messenger and being stuck with an old MSN Messenger app.

Ever keen to get new people to try Linux I asked her if she was ok with me installing an OS and completely getting rid of windows. She never really plays games with it other than solitaire and mainly just uses it for the Internet "The perfect candidate for Linux" I thought to myself. With complete trust in me she agreed and when I asked if she was sure at getting rid of windows before I hit the return key she said "yep Kill it!" and with that the hard drive was formatted to ext4 and XP annihilated.

I had a bit of trouble at first as I didn't have an Ubuntu install disk on me (I chose Ubuntu over any other distro as I figured it'd be best for a new convert). So I used her Windows to download the ISO only to find out that I couldn't get any app in the OS to burn the image to disk. I managed to overcome this, luckily I had a copy of pupy 4.0 live cd. There was only one optical drive so I had to run puppy from ram, once booted I mounted the windows Drive and was able to burn the Ubuntu image to CD.

Once it was all installed and I set it up for her (installed restricted extras, libdvdcss, aMSN, compiz, VLC etc.) I showed her a few things to get going and let her play about with it. The overall result was good, She was impressed with it saying "It's like I've got a new computer". The one thing she spent the most time on was aMSN (I told her about empathy but didn't seem interested) I noticed in one of her IM's her saying "I've got the new MSN messenger now". I didn't bother trying to explain the difference but it goes to show that from an end user's point of view Windows / Apple / Linux / BSD it's all the same and the underlying technology doesn't matter as long as it does what they expect it to do.

Wednesday, 18 November 2009

Nothing Karmic about it.

I've had Ubuntu Karmic installed in both my Desktop and EEEPC since just after the release day, once installed I was quite impressed. Everything worked well, I was in awe over the X-splash effect and the cinematic shut down plus the improvement in boot up and shut down speed. I even like the extras such as Empathy, Evolution and the new Software Centre. A few weeks in though and some updates later every thing's going tits up. My FaceBook plugin for Empathy gave in the ghost, Gwibber has been very twitchy and Kaffeine pre 1.0 is pants.

I may look into trying to fix these annoyances or maybe stick it out in hope an update will fix them for me, I don't know if I want to spend my time tweeking till it works. A part of me wishes that I'd stayed with Jaunty but hope Karmic will improve seeing as we're heading into an LTS edition in April. Small annoyances they may-be but if they don't get fixed it'll just bug the hell out of me and I may make the switch to another Distro like Mint or something, Hell I might even give Slackware a go!

Saturday, 17 October 2009

Doctor Who Exhibition Glasgow 2009

Earlier this summer we went on a trip to Glasgow to see the Doctor Who Exhibition. If you're a bit of a Time Lord fan like myself you may appreciate these pictures.