This is the first technical post in this blog.
Maybe it will be too simple for experienced audience, but one of the most frustrating things you can live if you work with computers is that even the installation of a product or software fails, and installing Glassfish at its current version has some tricks I wanted to comment. And maybe, if you are starting just now, it can help you.
If you want to install a Glassfish server in a production environment follow these steps. For a development environement maybe is better to use another method that I explain in this post.
The objective will be:
- Install Glassfish 126.96.36.199: I will install on a Windows 7 64 bit Virtual Machine (see Development Environment).
- Update EclipseLink to version 2.4.0: I will update EclipseLink coming with Glassfish (2.3.3) with the latest version (2.4.0), released in June 2012.
Install Glassfish 188.8.131.52
I assume you have already the installation file that you can get at http://glassfish.java.net/downloads/184.108.40.206-final.html. Because this is a Windows installation I prefer to choose the Windows Installer in its full platform multilingual installation (glassfish-220.127.116.11-windows-ml.exe).
I also assume that you have you Java SDK installed (jre) installed. In my case I am using JDK 7 u5.
The first trick comes even to execute the installation file. Because it’s a 64 bit installation the installer can’t find the Java Runtime environment. It will show you a message like this:
At least the message is clear. So you need to execute the installer from the command line, with a sentence like this, assuming you have the installer on the desktop:
glassfish-18.104.22.168-windows-ml.exe -j "C:\Program Files\Java\jre7"
You will get a wizard-style installation. After passing the first presentation screen of this wizard you will be asked to choose the installation type between “Typical” or “Custom” installation. In the past I have had some troubles with Custom installation, but now the main problem comes with the Typical installation. So we will choose Custom installation and we will follow these wizard steps:
- Install and Configure
- Select default installation folder (c:\glassfish3) or change it as you wish.
- Select the JDK you want to use as Java Runtime for Glassfish. Generally it detects the Java version you have installed.
- On the next screen it gives you the opportunity to install and enable Update tool. I don’t recommend to install nor enable it if you are in a production environment, especially because I have read some articles referring to several troubles with the update tool. By now we will choose to not to install it.
- Finally push Install button to start installation.
The installation is fast. After finishing we will follow these steps to create a domain:
- Choose option “Create a server domain”
- Configure the server domain: you have to choose a name, admin and http ports, and username and password for admin user. Because this is a development installation we will not create a service for the server and we will not start the domain after finishing the installation (uncheck both check boxes at the end of this screen)
After choosing configuration parameters, press Next and you will have your domain installed and configured. The domain will not be started if you choose to not to start it, so we can start it from Eclipse, for example.
What happens if I wanted a Typical installation ?
The answer is: you will have a problem when creating the domain in the last step of the wizard installation. The problem comes because the installer doesn’t know the path to JDK. You have to do a trick after the installation of Glassfish but before creating the domain as shown before.
When arriving to the step of domain configuration (domain name, admin name and password, etc…) go to
C:\glassfish3\glassfish\config and edit file
asenv.bat At the end of the file specify the JDK folder that you have changing line AS_JAVA. For example:
set AS_JAVA=C:\Program Files\Java\jdk1.7
After that continue the installation and it will work. As you see it’s really bizarre to do this with an installer.
Last step: updating EclipseLink to the last version (2.4)
This step is not really necessary. Glassfish 22.214.171.124 comes with EclipseLink 2.3.3 as default JPA provider. But EclipseLink 2.4 introduces several nice features at Java Persistence Query Language Extensions that I am using right now at work and makes my live easier. And I want to include this version with my installation of Glassfish.
These steps have worked for me, although I’m not sure if it’s the best way to achieve this.
- Download Eclipselink 2.4 OSGi bundles from EclipseLink site and unzip file somewhere on your disk
- Assuming you installed Glassfish at
C:\Glassfish3, go to
C:\Glassfish3\glassfishand make a backup copy of folder
- Delete all jar files in
modulesfolder beginning with
- Copy to folder
modulesall jars from the downloaded and unzipped file beginning with
org.eclipse.persistencebut not containing source (you probably don’t need it). In this case I have copied these files. Maybe not all are necessary for your purposes.
- If you have started at least once the server before you will need to delete the content of Felix cache folder inside your domain’s folder. For example assuning you have a domain called MainDomain you will have to delete contents of folder
After that you can start Glassfish! Good luck !
Update 06/09/2012: I have just realized that last step (deleting content of folder
C:\glassfish3\glassfish\osgi\felix) was wrong. I have updated this post to correct this. You have to delete the contents of felix chache folder inside your domain folder
Cardedeu, July, 30 2012.