ICE09 . playing with java, scala, groovy and spring .

Playing with Spring

Archive for the ‘GlassFish’ Category

Preparing a fresh Debian Lenny for Java Enterprise Applications

Posted by ice09 on December 18, 2010

Intention

I am a happy owner of a virtual root server – this being a great thing, there is one big problem: I have to prepare this box for Java usage myself. This must be achieved with a somewhat limited Linux knowledge. However, with debian lenny this turned out to be a breeze.

I had to follow the steps below to get this running in about 30 minutes:

  1. Apache Webserver
  2. MySQL
  3. phpMyAdmin
  4. GlassFish 3

Which is pretty much what you need for creating JEE/Spring-Applications in an enterprise scale.

What is still missing (due to a lack of time and necessity) are the following configurations:

  1. JNDI-Resource for the MySQL-Database
  2. Apache/GlassFish-mod for forwarding requests on port 80 to GlassFish directly

List of Commands

cat /etc/debian_version

For my installation this says 5.0.7. So obviously: 1. I am using Debian. 2. It is Debian Lenny in version 5.0.7. Yes, we are starting slowly here.

apt-get install apache2

Install the Apache Web Server. I more or less need it for phpMyAdmin. Obviously, you can choose lighthttpd or others here.

apt-get install mysql-server mysql-client phpmyadmin

This is the most important line, it magically does everything exactly like you want to have it (however, this depends on answering the questions during installation correctly).

apt-get install sun-java6-jdk

Ok, this is important as well for Java development. I did not expect it to be that easy (remembering licensing issues in the past) and tried it “manually”, but was lost almost immediately. However, with sun-java6-jdk, you will get everything you need. You should check this with:

java –version

which should print out text like this:

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

Your mileage may vary here of course. It should show 1.6 somewhere though.

Now, the most “difficult” part is the installation of GlassFish. Not surprisingly, we are not the first trying to install GlassFish on Debian, so there exists a really good documentation about this topic here (in German): http://www.bennyn.de/webanwendungen/virtual-server/glassfish-v3-installieren-auf-debian-lenny.html

Since this HOWTO here should be complete, I am reposting the steps here:

wget -O /opt/glassfish-3.0.1.zip http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip
cd /opt/
unzip glassfish-3.0.1.zip
rm glassfish-3.0.1.zip
cd /etc/init.d/

Now, only the script glassfish.sh is missing:

vim /etc/init.d/glassfish.sh
touch glassfish.sh
chmod 0755 glassfish.sh    
update-rc.d glassfish.sh defaults

with this content (all taken from the site mentioned above):

#!/bin/sh
### BEGIN INIT INFO
# Provides:          glassfish
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
#
# This init.d script is used to start the glassfish application server.
# Simplest possible case -- no password file, one default domain
#
 
GLASSFISH_HOME=${GLASSFISH_HOME:-"/opt/glassfishv3/glassfish"}
 
case "$1" in
start)
	$GLASSFISH_HOME/bin/asadmin start-domain | tee -a /var/log/glassfish.log
	;;
stop)
	$GLASSFISH_HOME/bin/asadmin stop-domain | tee -a /var/log/glassfish.log
	;;
restart)
	$GLASSFISH_HOME/bin/asadmin restart-domain | tee -a /var/log/glassfish.log
	;;
*)
    echo "usage: $0 (start|stop|restart|help)"
esac
Advertisements

Posted in Debian, GlassFish | 2 Comments »