Gaz's picture

Update: I've built the basic outline of a GlassFish v3 appliance with tklpatch. While already operational, it could certainly do with some improvements. The GlassFish tklpatch is now finished! Note that GlassFish requires a minimum of 1GB of RAM (2GB recommended), so make sure to size your virtual machines accordingly.

Because GlassFish v3 and the latest Sun JDK 6 are not available via the standard repositories, my tklpatch uses a manual installation. The resulting ISO is 275MB, which is a considerable jump on the standard TurnKey Core at 112MB. The attached tklpatch (glassfish.tar) is not a complete tklpatch, please run the script provided in the TAR file and read the instructions below.

Firstly we are going to set ourselves up with a development environment. Secondly we will build  our appliance.

A) Installing the development environment

  1. Download the TurnKey Core edition from
  2. Install in VirtualBox with 512MB of RAM on a >=5GB disk with two network adapters, a HostOnly (to allow access from host) and a NAT (to allow internet access).
  3. Run the virtual machine using the TurnKey Core ISO
  4. Install to Hard Disk
  5. Select the install to hard disk option
  6. Use guided partitioning
  7. Write changes to disks
  8. Set root password
  9. Unmount ISO, restart

B) Download and install development software

  1. SSH into the turnkey client
  2. Update the repository
    root@core:~# apt-get update
  3. Install TKLPatch
    root@core:~# apt-get install tklpatch

C) Create a Glassfish v3 Appliance

Note: We need to install Sun JDK manually to get the latest version as required by GlassFish. We also need to install GlassFish manually as it isn't in the repositories (yet).


  1. Download the Sun Java SE JDK 6u18 from the internet. Choose the *.bin (non-RPM) download from
  2. Download Glassfish v3 Final full (not web profile) from
  3. Download the attached glassfish.tar file
  4. Use SCP over SSH (FileZilla) to copy the three downloaded files above into the virtual machine. Also copy over the TurnKeyLinux Core ISO.
  5. Extract the tar file
    root@core:~# tar -xvf glassfish.tar
  6. Run the script to build your ISO
    root@core:~# ./
  7. Test in a virtual machine!


That's it! Some notes:

  • The application server is automatically started by a script at /etc/init.d/glassfish which has configuration files in the /home/glassfish/autodomains directory.
  • The application server runs under the glassfish user not as root.
  • The default passwords provided by GlassFish are used.


Alon Swartz's picture

Excellent documentation, nicely done! It would be great if you could attach a patch without the downloaded files so it would be a little easier to test the patch (sort of a patch template).

BTW, I created an entry of glassfish in the TKLPatch section of the development wiki linking here, feel free to update it as you see fit.
Gaz's picture

I've posted the patch as an attachment with a shell script that runs all of the steps that were previously listed. Simply follow the directions in the posting above.

Paul Morris's picture

This saved me a lot of work. Thanks for sharing.

Manuel's picture

Is this Linux + Apache + Glassfish?

Gaz's picture

No, this is Linux + Glassfish only. Glassfish has its own web server. But you could configure it to go via Apache if you want. However this is more common with Tomcat deployments than with Glassfish.

Graham Stewart's picture

Could some one update this please, or provide manual instructions to install jdk-7u25-linux-x64.tar.gz and (glassfish) to turnkey-core-12.1-squeeze-amd64-vmdk.

Oracle no longer provides the .bin of the jdk so I can not just change the file names in the shell script and I have limited experince with shell scripts in any case.

I only need to apply this to one VM so I would prefer to just add the files to the vmdk rather then build a patched iso.

Graham Stewart's picture

I managed to get a glassfish server running on a TKL core. The following are the steps I  used. No guarantees that this will work for others.

Download the latest tkl-core vm I used the amd64-vmdk and imported into my esxi 5 server using the vmware convertor. You should at this stage increase the memory to 1Gb otherwise glassfish will be very slow as I found out and had to do it later. Set up your network and timezone as required.

Download the latest version of Java JDK, I used the x64 tar.gz and glassfish, I used the  Linux/Unix/Mac Zip.

Uploaded these to the vm, I used web min file manager, and extract to your dir of choice, I used /etc. I am not a LInux expert so I am not sure of the proper locations. The files will extract to the current dir, ie /etc. I had to change the owner of the java JDK folders and files to root:root as they were showing user 500:137

Next, set the JAVA_HOME in /etc/profiles. You can set the PATH if you want to. I had a heap problems working this out because the PATH in /etc/profiles was being overwritten by the PATH in /root/.bashrc and the script files in /root/.bashrc.d when I was logged in as root via both ssh and the vm console. Read man bash for more details. In any case it is best to set AS_JAVA = /etc/jdk<version> where <version> is the version of your jdk download in /etc/glassfish3/glassfish/config/asenv.conf

The default domain is started by running asadmin start-domain in /etc/glassfish3/glassfish/bin. the gui web admin tool can be accessed on port 4848 of your server but you will need to run asadmin --host <servername> --port 4848 enable-secure-server and restarting the domain before doing so. The applications in the domain are on port 8080. The default domain can be set to start on boot by using asadmin create-service.

Hope this helps


Add new comment