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

Playing with Spring

Preparing a fresh Debian Lenny for Java Enterprise Applications

Posted by ice09 on December 18, 2010


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):

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

wget -O /opt/
cd /opt/
cd /etc/init.d/

Now, only the script is missing:

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

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

# 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.
# This init.d script is used to start the glassfish application server.
# Simplest possible case -- no password file, one default domain
case "$1" in
	$GLASSFISH_HOME/bin/asadmin start-domain | tee -a /var/log/glassfish.log
	$GLASSFISH_HOME/bin/asadmin stop-domain | tee -a /var/log/glassfish.log
	$GLASSFISH_HOME/bin/asadmin restart-domain | tee -a /var/log/glassfish.log
    echo "usage: $0 (start|stop|restart|help)"

2 Responses to “Preparing a fresh Debian Lenny for Java Enterprise Applications”

  1. Alex said

    I have learn a few excellent stuff here. Definitely
    price bookmarking for revisiting. I surprise how so much attempt you set to make the sort of excellent
    informative site.

  2. Katherine said

    Pretty! This has been an extremely wonderful post.

    Thanks for supplying this information.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: