Using the Netbeans IDE together with Glassfish as application server is quite easy and comes out-of-the box with the Netbeans installer. To install PostgreSQL is not significantly harder to install on Linux (or Windows). Our team uses Ubuntu 9.10, Netbeans 6.8, Glassfish and PostgreSQL 8.4.2. If you work alone, it is usually no problem to develop and deploy locally but once you are embedded into a team, you better ensure that you deploy and test applications in the same environment. Very quick you will have Ubuntu updating the OS and PostgreSQL and someone might install Glassfish updates or even add optional modules, soon you have as many deployment environments as you have team-members (times 2). The straight forward answer would be to have all working with the same one server running the application server and the DB, but we still need the comfort of a local sandbox playground and in-dependency from being online or in the office. Certainly I do not advocate island development leading to a different codebase and varying DB’s. But after the tutorial you will agree with me our solution is a reasonable approach.
Our approach: We create a virtual server (with VirtualBox) that everyone is running on his/her desktop and also one instance on a central server. One team-member is responsible to create so-called raw virtual images of the server and documents new versions that are deployed to each desktop. Each team-member does nothing but starting the guest Server in VirtualBox (Glassfish and PostreSQL autostarting) and immediately can connect with Netbeans and pgadmin to AS and DB.
Not all developers are familar with setting up Ubuntu Server and VirtualBox, so I compiled this tutorial as a walk-through the necessary steps to get you started witthout knowing too much about the OS nitty-gritty stuff. You want to concentrate on creating your application, not learning to hack the operating system (even I recommend to know as much as possible on Linux).
A remark on the naming: Your desktop or Notebook running VirtualBox is the HOST and the server or OS you run in the virtual machine is the GUEST.
Products used in this tutorial:
- Ubuntu 9.10 Desktop (host) and 9.10 Server (guest)
- Netbeans 6.8
- Glassfish V3 (comes with NB 6.8)
- PostgreSQL 8.4.x
- VirtualBox 3.1.x (required 3.x and higher)
- pgAdmin III as GUI for PostgreSQL
- Installed Netbeans with a local installed Glassfish V3 (without a local installation of Glassfish you cant connect to a remote, aka virtual, server later).
- Installed pgadmin (you find it the Ubuntu Software Center or at pgadmin.org)
- You should be online, your guest system needs to download package during the installation. VirtualBox ensure your virtual machine taps on the network connection of your desktop.
Required Hardware (host):
- The better your host hardware in terms of available memory and fast cores the better. Even the performance of VirtualBox is really amazing, with more horsepower things just getting much smoother. My mobile working environment is a Intel 8400 Notebook with 4GB of memory giving me enough performance to work on the road or doing demos.
Personal remark on the tutorial:
- I explain from the viewpoint of someone who never touched virtualbox or Linux (in case you install the server in VirtualBox for Windows)
- If that is too easy for you, then skip the parts you are experienced in !
Tutorial Part 1
covers the creation of a Ubuntu Server with VirtualBox, in part 2 we will discuss the remaining installation steps and housekeeping.
- Installation of VirtualBox
If you dont have done so yet, go to virtualbox.org and either download the deb (install) file or follow the instructions there to add it to your sources.list.
Remark: Using the deb package, you might get an error due to conflicts with an previous version, if you have one. You can get rid of it with sudo apt-get remove virtualbox-3.0 (please use correct version number).
- Download the Ubuntu Server ISO
Installer CD from ubuntu.com. We use the server version that comes without Gnome (the OS “GUI”) to have a small footprint and server usually dont require a graphical frontend.
- Add the Ubuntu Server ISO file to the virtual images
You dont need the real installer CD/DVD, but you can add the ISO file to the Virtual Media Manager (under file|Virtual Media Manager).
- Create a new virtual machine and a virtual harddisk with the assistant.
This part is the easiest of the whole exercise. You can stick pretty much to all the proposed default values except memory, I recommend to give the guest at least 1GB of memory.
- Update Settings of the new guest system (attach CD)
After the previous step you find a new (the first?) virtual machine in the list on the left. Select it and go to Settings. Attach the Ubuntu Server ISO to the virtual machine.
The other settings we will take care of later.
- Start the virtual machine
It will boot from the virtual CD (default) and show the installation start screen soon.
Choose Install Ubuntu Server. There are some more dialogs asking for language, keyboard, hostname (the name for the guest system!), username/password which are mostly self-explaining.
Please note, this not a GUI, you cant click with your mouse, use the arrow keys, tab and enter to select options and actions !
I recommend to use the guided partition – entire disk (standard without LVM and encryption, which we dont need for our purpose)
You need to confirm the changes with YES (use tab to change from NO)
I recommend to select NO automatic updates (we need to control/trigger the update process manually for proper reference points). At a later stage I will describe the necessary housekeeping to maintain the virtual server.
At this point we need to decide, if we want to go for a “naked” server without anything installed (which is a good choice if you want to have a clean server that you can use as base for future use), or if we install (for our purpose) PostgreSQL. (Navigate with cursor, tab and return to continue)
At this stage the installation is finished and the server presents a login. I recommend to log in and shut down to adjust some of the settings. The quick (and dirty) way is to close the window (X) and answer shutdown server (a bit like pulling the plug, I wont do that once you have production data and services running). I do that quite often and had never problem though.
The proper way would be to log in, change to root user with sudo -i (give your user password) and init 0 (zero).
- In Part 2 we will finalize the server and VirtualBox settings.