November 14, 2007

Glassfish on Ubuntu.. howto

EDIT: It has come to my attention that this starts glassfish with root privileges which wouldn’t be good if this wasn’t a test server! A alternative (and better method) can be found at link cheers Jasper.

One of my colleagues has a java based webpage that he is developing and we have been testing different hosting software… finally settling on Glassfish. I was searching the web for an easy howto and there doesn’t seem to be one so I have written my findings here.
  • Next you need to decide where you want to install it… Personally, I like programs to be installed into /usr/local/appname. So you will need to copy the install.jar to /usr/local (the jar will extract files into a glassfish folder).
  • Next you follow the steps on the webpage above… so basically…

sudo -s
ENTER PASSWORD
java -Xmx256m -jar glassfish-installer-v2-b58g.jar
cd glassfish
chmod -R +x lib/ant/bin
lib/ant/bin/ant -f setup.xml

  • Next you can either start it with the command

/usr/local/glassfish/bin/asadmin start-domain domain1

  • Or better create a init.d file to start and stop it…

gedit /etc/init.d/glassfish

GLASSFISHPATH=/usr/local/glassfish/bin
case ”$1” in
start)
${GLASSFISHPATH}/asadmin start-domain domain1
;;
stop)
${GLASSFISHPATH}/asadmin stop-domain domain1
;;
restart)
${GLASSFISHPATH}/asadmin stop-domain domain1
${GLASSFISHPATH}/asadmin start-domain domain1
;;
*)
echo $”usage: $0 {start|stop|restart}”
exit 1
esac

  • save and exit
  • chmod a+x /etc/init.d/glassfish
  • to have glassfish start during boot (and stop during halt)

ln -s /etc/init.d/glassfish /etc/rc1.d/K99glassfish
ln -s /etc/init.d/glassfish /etc/rc2.d/S99glassfish

Well, its not a great howto but then the install was pretty simple


- 5 comments by 1 or more people Not publicly viewable

  1. Chris

    Andrew,

    A great article and right on time! I recently installed Glassfish v2 on Ubuntu 7.10 but when I bashed:

    lib/ant/bin/ant -f setup.xml <= This blew-up

    First, I didn’t have Ant. I installed Ant from the Ubuntu Package archive. No problem.

    I have Java installed…

    chris@JavaDev:~$ java -version
    java version “1.6.0_03”
    Java™ SE Runtime Environment (build 1.6.0_03-b05)
    Java HotSpot™ Client VM (build 1.6.0_03-b05, mixed mode, sharing)

    When I try to rebuild the setup.xml with Ant I get the following…

    root@JavaDev:/usr/local/glassfish# lib/ant/bin/ant -f setup.xml
    Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-sun-1.6.0.03/lib/tools.jar
    Buildfile: setup.xml

    all:

    get.java.home:

    setup.init:

    check-java:

    get.java.home:

    setup.init:

    validate-java:
    [echo] Current Java Version 1.6.0_03

    BUILD FAILED
    /usr/local/glassfish/setup.xml:156: The following error occurred while executing this line:
    /usr/local/glassfish/setup.xml:136: The following error occurred while executing this line:
    /usr/local/glassfish/setup.xml:132: Please set java.home to a JDK installation

    Total time: 7 seconds

    I made sure I selected the latest version of Java (1.6.0.03)...

    root@JavaDev: sudo update-alternatives—config java

    I edited the Java environment variables…

    root@JavaDev. gksu gedit /etc/environment

    JAVA_HOME=”/usr/lib/jvm/java-6-sun-1.6.0.03”
    CLASSPATH=”.:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/rt.jar”
    PATH=”/usr/lib/jvm/java-6-sun-1.6.0.03/jre/sbin:/usr/lib/jvm/java-6-sun-1.6.0.03/jre/bin:/usr/sbin:/usr/bin:/sbin:/bin:/us r/games”

    But still… Glassfish can’t find the tools.jar file. I searched for tools.jar on the entire drive and I can not it. Can you help?

    Thanks in advance Andrew.

    08 Dec 2007, 19:29

  2. Chris

    Andrew,

    I worked it out. I did not have the JDK 6 installed (I only installed J2EE 5 w/o the JDK). But I have another question: how do you validate that Glassfish starts after a boot. I have not seen it in System Monitor as a process. Is my script working properly?

    Chris

    09 Dec 2007, 06:48

  3. A quickway to find out if it was running would be to use your web browser and locate the home page which will be something like http://localhost:8080 if you didn’t change the ports.
    Alternatively, you could try logging into the admin section just change the port (8080) to 4848.

    11 Dec 2007, 08:50

  4. Oh, and to check that your init.d script works you can just try: -
    • sudo /etc/init.d/glassfish stop
      To stop glassfish
    • sudo /etc/init.d/glassfish start
      To start glassfish or,
    • sudo /etc/init.d/glassfish restart
      To do both.

    Hope that helps.

    11 Dec 2007, 08:53

  5. Jasper

    Thanks for the tutorial. It was very helpful. I made some improvements and additions and wrote about it in my blog.

    15 Jan 2008, 22:17


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

November 2007

Mo Tu We Th Fr Sa Su
Oct |  Today  | Dec
         1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30      

Search this blog

Tags

Galleries

Most recent comments

  • Thanks for the tutorial. It was very helpful. I made some improvements and additions and wrote about… by Jasper on this entry
  • Oh, and to check that your init.d script works you can just try: – sudo /etc/init.d/glassfish stop T… by on this entry
  • A quickway to find out if it was running would be to use your web browser and locate the home page w… by on this entry
  • Andrew, I worked it out. I did not have the JDK 6 installed (I only installed J2EE 5 w/o the JDK). B… by Chris on this entry
  • Andrew, A great article and right on time! I recently installed Glassfish v2 on Ubuntu 7.10 but when… by Chris on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXIX