Saturday, June 8, 2013

Installing Glassfish 3.1.2.2 on Debian

Typical installation process consist of the following steps:

Step 1: To install Glassfish 3.1.2.2 on Debian you have to have installed appropriate JDK. Minimum and certified versions for Glassfish 3.1.2.2 are Oracle's JDK 1.6.0_31 and JDK 7 Update 3. That means these are the minimum versions you want to use.

Download last JDK version. In our case it will be 6.0.45 for x64 machines, eg. jdk-6u45-linux-x64.bin

Extract Oracle's JDK in your home folder:
./jdk-6u45-linux-x64.bin

Typically JDK would be extracted to autocreated directory (in our case jdk1.6.0_45). Move this folder to /usr/lib/jvm.
mv ./jdk1.6.0_45 /usr/lib/jvm/jdk1.6.0_45

Create (or modify) symbolic link java-6-sun in /usr/lib/jvm/
Next modify permisiions
chgrp -R root /usr/lib/jvm/jdk1.6.0_45
chown -R root /usr/lib/jvm/jdk1.6.0_45

If you are replacing previous version make sure environment points to a valid install - update alternatives
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_45/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_45/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_45/bin/javaws" 1
update-alternatives --config java

Step 2: Prepare operating system envinronment to install and run Glassfish.
Add a new user called glassfish
adduser --home /home/glassfish --system --shell /bin/bash glassfish

Add a new group for glassfish administration
groupadd glassfishadm

Add your users that shall be Glassfish adminstrators
usermod -a -G glassfishadm root
usermod -a -G glassfishadm my_glassfish_admin

Create and set environment variables JAVA_HOME and AS_JAVA globally for all users (only for bash). Edit /etc/bash.bashrc and append the following lines:
export GLASSFISH_HOME=/home/glassfish/glassfish3
export JAVA_HOME=/usr/lib/jvm/java-6-sun
#we will set this here because it might prevent problems later
export AS_JAVA=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin:$GLASSFISH_HOME/bin

Reload bashrc
exec bash

#Eventually you can set JAVA_HOME and AS_JAVA for everyone (best place for setting env vars globally). To do this edit /etc/environment and append the following lines:
JAVA_HOME=/usr/lib/jvm/java-6-sun
GLASSFISH_HOME=/home/glassfish/glassfish3
#we will set this here because it might prevent problems later
AS_JAVA=/usr/lib/jvm/java-6-sun

If you dont't have "unzip" installed run this here first
apt-get install unzip

Step 3: Install and run Glassfish Now switch user to the glassfish user we created before (see below)
su glassfish
Change to home dir of glassfish
cd /home/glassfish

Download glassfish Open Source Edition Full Platform
wget http://download.java.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2-unix.sh
or Web Profile from http://download.java.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2-web-unix-ml.sh

Install Glassfish
chmod +x ./glassfish-3.1.2.2-unix.sh
./glassfish-3.1.2.2-unix.sh -s

Exit to root
exit

Change group of glassfish home directory to glassfishadm
chgrp -R glassfishadm /home/glassfish/glassfish3

Just to make sure: change owner of glassfish home directory to glassfish
chown -R glassfish /home/glassfish/glassfish3

Make sure the relevant files are executable/modifyable/readable for owner and group
chmod -R ug+rwx /home/glassfish/glassfish3/bin/
chmod -R ug+rwx /home/glassfish/glassfish3/glassfish/bin/

Others are not allowed to execute/modify/read them
chmod -R o-rwx /home/glassfish/glassfish3/bin/
chmod -R o-rwx /home/glassfish/glassfish3/glassfish/bin/

Now switch user to the glassfish user
su glassfish

Start glassfish
/home/glassfish/glassfish3/bin/asadmin start-domain domain1
Check the output:

Waiting for domain1 to start .....
Successfully started the domain : domain1
domain  Location: /home/glassfish/glassfish3/glassfish/domains/domain1
Log File: /home/glassfish/glassfish3/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

Stop glassfish
/home/glassfish/glassfish3/bin/asadmin stop-domain domain1
Check the output:

Waiting for the domain to stop ...
Command stop-domain executed successfully.

Exit from glassfish user
exit

Create file /etc/init.d/glassfish and paste the lines below
#! /bin/sh
#to prevent some possible problems
export AS_JAVA=/usr/lib/jvm/java-6-sun
GLASSFISHPATH=/home/glassfish/glassfish3/gbin
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
su - glassfish -c "$GLASSFISHPATH/asadmin start-domain domain1"
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
su - glassfish -c "$GLASSFISHPATH/asadmin stop-domain domain1"
;;
*)
echo $"usage: $0 {start|stop|restart}"
exit 3
;;
esac
:

Save the file

Add init script to the runlevels, to start glassfish when system starts.
To do this make the init script file executable
chmod a+x /etc/init.d/glassfish

Next configure Glassfish for autostart on ubuntu boot
update-rc.d glassfish defaults

Test if glassfish starts
/etc/init.d/glassfish start

And voila ... it works!

Tuesday, June 4, 2013

JSF Components Wizard: new webpage, new release, new documentation

To get more info visit: http://jcw.jsfportal.org/



JSF Components Wizard is a visual code generator, which can be helpful for each JSF developer.