I've been using Tomcat for some time but I'd like to use Glassfish V3 instead as I think it's (going to be) an amazing application server. This is a tutorial based on how I installed it on Ubuntu 9.04 Jaunty Jackalope.
If you haven't install JDK6 do that first.
sudo apt-get install sun-java6-jdk
Get glassfish (I use the zip file as the sh file didn't complete the download).
wget http://download.java.net/glassfish/v3-prelude/release/glassfish-v3-prelude.zip
Unziping glassfish (I didn't have unzip so I installed it first by running:
sudo apt-get install unzip )
sudo unzip glassfish-v3-prelude.zip
Move it to the opt folder
sudo mv glassfishv3-prelude /opt
First add a glassfish system user
sudo useradd --system glassfish -d /opt/glassfishv3-prelude
Set admin group
sudo chgrp -R admin /opt/glassfishv3-prelude
Set glassfish as the owner
sudo chown -R glassfish glassfishv3-prelude
Go into the install directory
cd glassfishv3-prelude
Set the executable files:
sudo chmod -R +x bin/
sudo chmod -R +x glassfish/bin/
Start the default glassfish domain (domain1)
sudo -u glassfish bin/asadmin start-domain domain1
To have Glassfish start automatically when you start Ubuntu. You need to add a
glassfish file to the /etc/init.d/ folder. Pick you favorite editor (I use vim).
sudo vim /etc/init.d/glassfish
Enter the following:
#! /bin/sh
GLASSFISHPATH=/opt/glassfishv3-prelude/bin
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1
;;
*)
echo $"usage: $0 {start|stop|restart}"
exit 3
;;
esac
:
Changing the users rights
sudo chmod a+x /etc/init.d/glassfish
Then install it on all runlevels:
sudo update-rc.d glassfish defaults
That is it! I hope this tutorial was helpfull.
I got help from all around the world to complete this tutorial but special thanks to computing with jasper.
23 comments:
Excellent walk through, worked perfectly for what I need it to do!!
I'm glad that it was useful:-)
Excellent! Works great!
Thank you for the excellent instructions.
I installed Glassfish in turnkeylinux.org core virtual machine appliance and it worked perfectly. The only problem I encountered was an error about sun-java6-jdk not being found. That error was fixed by making sure multiverse repository is isn't commented in /etc/apt/sources.list.d/sources.list.
There wasn't an admin group in the TurnKey VM, so I just left it as root.
@BrokenSpoke
Thank you for your input. I haven't tried turnkeylinux.org, but I'm happy that this howto could be applied for it as well.
error
on this line
sudo -u glassfish bin/asadmin start-domain domain1
Please let me know what might be wrong.
using ubuntu 9.10 and jdk6
thanks
Difficult to figure out what's wrong based on your comment. I guess that it can be any number of things. It might be a problem with the user glassfish not having the right authorities if it created right. It might be with access to the asadmin command which means that you are executing it from the wrong location. Check that you have entered the installed directory. The last is that there might be something wrong with the domain (domain1) if everything else is set up correctly. The input you gave me didn't provide much information to go along with.
It might be the line in the init.d script
echo $”usage: $0 {start|stop|restart}”
Since this has curly brackets, not the normal boring ones.
Awesome, thanks for all the leg-work!
@ nreilly
You are right. I fixed the problem it should have been
echo $"usage: $0 {start|stop|restart}"
but was:
echo $”usage: $0 {start|stop|restart}”
Small error you hardly can see. Thank you for pointing that out.
I got that error message below;
"y@m2lud910:/opt/glassfishv3-prelude$ sudo -u glassfish bin/asadmin start-domain domain1
java.lang.NoClassDefFoundError: com.sun.org.apache.xerces.internal.parsers.DOMParser
"
What if the port is in use? how could I change the port?
About the java.lang.NoClassDefFoundError - It looks like you are missing the jar that should contain the com.sun.org.apache.xerces.internal.parsers.DOMParser java class. I would recommend to try to restart. If it doesn't help I would have reinstalled. However it might also be that the jar file in question is not readable for the user. Use the chmod/chown tools to fix that.
To change the port I would use the excellent asadmin tool or the web admin tool on 4848.
BTW: The dzone refcard for glassfish v3 is really helpfull: http://refcardz.dzone.com/refcardz/glassfish-application-server
in the final version of glassfish (3) the script does not work and sends a file not found error domain.xml. please your help in this regard
I think you will find you may have a permissons issue with the domain.xml file not found. Try starting it manually and you don't have the problem.
Nice how to!
Can you tell me if you're using a 64 bit Ubuntu?
@dnai:
I use the 64 bit version.
Hi, I develop a project in Netbeans, so now i want to deploy the war file but using the build.xml into console linux, and i'm having a problem when I try to do a 'run-deploy'.
I write:
$ ant -f build.xml run-deploy
and i have this response
Buildfile: build.xml
-pre-init:
-init-private:
-init-user:
-init-project:
-init-macrodef-property:
-do-init:
-post-init:
-init-check:
-init-macrodef-javac:
-init-macrodef-junit:
-init-macrodef-java:
-init-debug-args:
-init-macrodef-nbjpda:
-init-macrodef-nbjsdebug:
-init-macrodef-debug:
-init-taskdefs:
init:
-init-cos:
deps-module-jar:
deps-ear-jar:
deps-jar:
-pre-pre-compile:
-pre-compile:
-copy-manifest:
-copy-persistence-xml:
-copy-webdir:
library-inclusion-in-archive:
library-inclusion-in-manifest:
-do-compile:
-post-compile:
compile:
compile-jsps:
-do-compile-single-jsp:
-pre-dist:
-do-tmp-dist-with-manifest:
-do-tmp-dist-without-manifest:
-pre-run-deploy:
-pre-nbmodule-run-deploy:
-run-deploy-nb:
-init-deploy-ant:
-init-cl-deployment-env:
-parse-sun-web:
[copy] Copying 1 file to /tmp
[delete] Deleting: /tmp/gfv31346929056
-no-parse-sun-web:
-add-resources:
-deploy-ant:
[echo] Deploying dist/myProject.war
[get] Getting: http://localhost:38035/__asadmin/deploy?path=/home/rodolfo/myProject/dis...
[get] To: /tmp/gfv31081734299
[get] Error opening connection java.io.FileNotFoundException: http://localhost:38035/__asadmin/deploy?path=/home/rodolfo/myProject/dis...
[get] Error opening connection java.io.FileNotFoundException: http://localhost:38035/__asadmin/deploy?path=/home/rodolfo/myProject/dis...
[get] Error opening connection java.io.FileNotFoundException: http://localhost:38035/__asadmin/deploy?path=/home/rodolfo/myProject/dis...
[get] Can't get http://localhost:38035/__asadmin/deploy?path=/home/rodolfo/myProject/dis... to /tmp/gfv31081734299
BUILD FAILED
/home/rodolfo/myProject/nbproject/ant-deploy.xml:50: Can't get http://localhost:38035/__asadmin/deploy?path=/home/rodolfo/myProject/dis... to /tmp/gfv31081734299
Could someone help me? please.
Great tutorial, it was just what I was looking for!
Great Tutorial! Worked instantly. Thank you very much.
after sudo -u glassfish bin/asadmin start-domain domain1
I get message tah another process uses port 4848 - but netstat shows nothing for this port and localhost:4848 gives error
Any idea?
hi,
i just came accross this here:
http://www.nabisoft.com/tutorials/glassfish/installing-glassfish-301-on-ubuntu
there you will see a detailed description of how to install glassfish on ubungu.
Great Tutorial! Grazie mille!! :)
Post a Comment