Getting started with the GlassFish application server
This page will allow you to get up and running with GlassFish v3 on shared web hosting with Anchor.
What is GlassFish?
The GlassFish Application Server and is currently under development by the GlassFish Community & Sun. GlassFish v3 has a modular, lightweight and extensible architecture.
GlassFish includes the ability to tune JVM and application server settings without the need to tweak XML files by hand.
To install GlassFish v3 you will need:
- SSH access to your hosting account, Anchor provides this with all Linux hosting services.
- The ability to manage long running processes
- 2 high network ports allocated for use on the loop back interface
- Some understanding of Java hosting terminology
If you are hosted with Anchor, please contact support via email and request 2 network ports on your shared hosting server for use with GlassFish.
We will pre-configure Apache with mod_proxy rules mapping your GlassFish control panel to the temporary domain.
- Login to your hosting account via SSH.
Use wget to download a copy of the latest v3 GlassFish release from https://glassfish.dev.java.net/public/downloadsindex.html to your home folder.
- This guide deals with v3 prelude release, although this guide should work for the earlier releases.
Pick the platform-independent download file packaged as a zip file.
Unpack the zip file. This will use roughly 100mb of your hosting account quota.
At this point you should have a local copy of the GlassFish application server in your hosting account. Please ensure you have requested the 2 local network ports for use with GlassFish. If you allocate ports to yourself, you may find your application server does not work or is killed unexpectedly.
Edit the file glassfishv3-prelude/glassfish/domains/domain1/config/domain.xml using a console text based editor, or you could download it and edit it locally then upload it once all the edits below are complete.
First you need to set a new port for the admin control panel to be listening on. Edit the line
<http-listener id="admin-listener" port="4848" address="0.0.0.0" default-virtual-server="__asadmin" server-name="" />
and change the port="4848 to use the first allocated network port.
Next you need to modify the first http-listener and change the port allocation to your second allocated network port. The line to edit looks like this:
<http-listener id="http-listener-1" port="8080" address="0.0.0.0" default-virtual-server="server" server-name="" />
Now confirm the second http-listener is disabled, the line should read
<http-listener id="http-listener-2" port="8181" enabled="false" address="0.0.0.0" default-virtual-server="server" server-name="">
If not, ensure it contains
Now we want to disable the JMX console, as it's not required for most users. Edit the line
<jmx-connector port="8686" address="0.0.0.0" security-enabled="false" name="system" auth-realm-name="admin-realm" />
and add enabled="false". The JXM console configuration should now read like this:
<jmx-connector enabled="false" port="8686" address="0.0.0.0" security-enabled="false" name="system" auth-realm-name="admin-realm" />
Finally we want to reduce the default JVM maximum memory usage to 256mb. Edit the line
and change the 512 to 256.
- Now save the file. You're done editing the configuration for now.
Starting GlassFish & Diving In
There are numerous ways you could manage the Java process that runs GlassFish, however for the sake of this guide we will keep it simple.
To start GlassFish call this asadmin management script with the start-domain option.
- This script will tell you what port the admin console is running on, it should be the first port allocated to you by support.
You should now be able to get access to the GlassFish administration on your temporary domain allocated at the URL /admin
The GlassFish content is now accessible at http://your.domain.tmp.anchor.net.au/
At this stage you can now use the administration panel to deploy applications or JAR files. You can also configure JDBC resources and tune JVM & GlassFish options.
It is recommended you review the links in the See also section below.
Automatic GlassFish startup
A simple, although less than ideal way to ensure GlassFish is started after a system reboot, is to add a crontab entry for your local user account.
Edit your crontab from the SSH console.
Add the line
@reboot /home/YOUR_ACCOUNT_NAME/glassfishv3-prelude/bin/asadmin start-domain
If you require a more robust solution, please contact support for more information about process management using monit or daemontools.