Tuesday, May 25, 2010

Sun Glassfish Installation

% java -version
The installation is very easy as the download file include all necessary files.
1. Download Glassfish into the directory the server should later run
2. Run:
% java -Xmx256m -jar filename.jar
This command will unbundle GlassFish and create a new directory structure rooted under a directory named 'glassfish'.
3. % cd glassfish
4. Set the execute permission for the Ant binaries that are included with the GlassFish bundle. If you have not the necessary permissions run the command as sudo (you have to put "sudo" before the command)
% chmod -R +x lib/ant/bin
% lib/ant/bin/ant -f setup.xml
5. start the server using the asadmin command. For that be maybe you first have to change the current directory to /glassfish/bin.
% asadmin Use "exit" to exit and "help" for online help.
6. next start the database simply needed to run
./asadmin
7. asadmin> start-database

7. and finally you can start the server...
asadmin> start-domain domain1 Starting Domain domain1, please wait.....
8. The server is now up and running. You can log into the web admin interface by the following url:
http://localhost:4848
Login as Admin - userid="admin", password ="adminadmin"
./asadmin start-domain domain1


Changing Default GlassFish v3 Prelude Port Numbers 4848, 8080, and 8181

When you create courses, you sometimes do crazy things like installing multiple GlassFish domain administration servers (DAS) in a single host.

When you install GlassFish, it gives you default port numbers of of 4848 (for administration), 8080 (for the HTTP listener), and 8181 (for the HTTPS listener). But what do you do if you want to change them?

I got a few ideas googling "asadmin port number" and the like but couldn't really find a good example. So, I figured out how you do it and thought I would post an example in case anyone finds themselves in the same predicament as I did today.

Here are some examples that work in GlassFish v3 Prelude:

1.To change the HTTP port to 10080:

asadmin set server.http-service.http-listener.http-listener-1.port=10080


2.To change the HTTPS port to 10443:

asadmin set server.http-service.http-listener.http-listener-2.port=10443


3.To change the administration server port to 14848:

asadmin set server.http-service.http-listener.admin-listener.port=14848



It's handy to know you can grep for server properties in GlassFish v3 Prelude as follows:

asadmin get server | grep listener

shows all the properties with the text "listener" in them.

In GlassFish v3 Prelude, you can set port numbers for administration and the HTTP listener in the installer - but not for the HTTPS listener. You might find yourself needing to explicitly specify the administration port in your asadmin command. For example:

asadmin set --port 14848 server.http-service.http-listener.http-listener-2.port=10443

Glassfish path

C:\glassfish\config\asenv.bat:

REM set AS_JAVA=C:\Program Files\Java\jdk1.6.0_04\jre/..
set AS_JAVA=C:\Program Files\Java\jdk1.5.0_16