|
Installing and configuring glassfish |
|
|
|
|
Written by Chintan Rajyaguru
|
|
Saturday, 15 July 2006 |
|
I wrote about doing some Java EE development on June 20 but didn't get a chance to move it forward due to a vacation and then a lot of work at work! Here is the glassfish installation and configuration. We will talk about Netbeans pretty soon.
Prerequisites
You must have downloaded and installed JDK 5.0 before installing glassfish. You can download JDK 5.0 from http://java.sun.com/javase/downloads/. You must also set JAVA_HOME environment variable to point to the jdk installation directory. For example, on my machine, I have installed jdk in C:\MySoftware\jdk1.5.0_07 so my JAVA_HOME points to C:\MySoftware\jdk1.5.0_07. It is also recommended that you add the following entry in the PATH variable: %JAVA_HOME%\bin. On one of my machines, I had to restart the machine after installing jdk before I could run the java -jar command described below to install glassfish.
Download
Download glassfish from https://glassfish.dev.java.net/public/downloadsindex.html . I picked V1 UR1 Build 01 14-June-06 because when I installed glassfish, this was the latest version available. Download this file in a directory one level higher than the desired <glassfish_home> directory. For example, if you wanted to install glassfish in C:\MySoftware\glassfish\, download the file in C:\MySoftware. At the end of the download, you should have a file named glassfish-installer-v1_ur1-b01.jar in C:\MySoftware directory.
Installation and configuration
Remember NOT to simply extract the contents of the jar file using a zip utility...
To install and configure glassfish:
- Open a command prompt, change to C:\MySoftware directory and run C:\MySoftware>java -Xmx256m -jar glassfish-installer-v1_ur1-b01.jar. If you downloaded a different version of glassfish, replace glassfish-installer-v1_ur1-b01.jar with your file name
- The step above just installs the server, it's not ready to be used yet. Before we can use the server, we must set it up. Glassfish server comes with ANT scripts to configure the server. Configuration steps setup the domain with ports defined in the setup.xml file. Change to a newly created glassfish directory using cd glassfish. The file setup.xml contains the following administration values. You can create multiple domains using different values of these parameters. For example, you can have domain1 listening on 8888, domain2 listening on 9999 and so on. Every domain created through setup.xml file results in a directory in <glassfish_home>\domains (notice domain1 directory in <glassfish_home>\domains after running the ANT task as described below)
- domain.name=domain1 (used in starting the stopping domain)
- instance.name=server
- admin.user=admin
- admin.password=adminadmin
- admin.port=4848
- instance.port=8080 (default port to access applications running on domain1)
- orb.port=3700
- imq.port=7676
- https.port=8181
- Before we setup the server using ANT, let's change some values in the ANT setup. This will change server's default port to 8888 from 8080. We are making this change because we are going to install Oracle eXpress Edition in the future. The admin console of Oracle XE listens on port 8080 and we don't want any conflicts while running both the servers at the same time. To change the default ports, open setup.xml in your favorite text editor and change ports 8080 to 8888 in the following line: <property name="instance.port" value="8080" />
- Enough fluff about the server, let's just run the ANT task and finish the installation. In, C:\MySoftware\glassfish> run C:\MySoftware\glassfish>lib\ant\bin\ant -f setup.xml. Note: Previous step uses ant.bat file located in <glassfish_home>\lib\ant\bin directory. The installation instructions given on the glassfish website simply lists the command like this: ant -f setup.xml. This will result in an the following error. Or, it will use the version of ANT available in your PATH.

- Using the relative path lib\ant\bin\ant ensures you will use ANT distribution that came with glassfish. When the ANT task completes running, test the installation.
- If you installed glassfish without changing the port (in step 3), you can change it later by changing <glassfish_home>\domains\domain1\config\domain.xml (just do a find/replace).
Testing the installation
-
Go to <glassfish_home>\bin and run asadmin start-domain domain1 command. Notice that the name domain1 comes from the ANT setup.xml file. The command prompt should look similar to the one shown here 
-
Once the server is running, access the server on http://localhost:8888 and you should see the following screen 
-
You can play with the server using a hello world application described at this location https://glassfish.dev.java.net/downloads/quickstart/index.html#ProcedureTo_Deploy_Hello_Autodeploy. The same page also has some other information e.g. packaging and deploying applications. To stop the server, use asadmin stop-domain domain1 command
|
|
Last Updated ( Saturday, 22 July 2006 )
|