How to install Tomcat 6 on Ubuntu 9.04

Apache Tomcat is a free and open source software implementation for JavaServlets, providing support for Java Server Pages (JSP). Many popular web-based applications use servlets. You may choose to run Tomcat with either Sun’s Java implementation or the OpenJDK implementation of Java.

Because Tomcat version 6 was included in Ubuntu 9.04, installing a working Tomcat server is reasonably straightforward. However, before we can start installing Tomcat itself, we must first install Java.

First Install Sun Java in ubuntu 9.04

Install tomcat 6 in ubuntu 9.04

sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples

This command downloads and install the following packages

tomcat6 : Servlet and JSP engine

tomcat6-admin : Admin web applications

tomcat6-common : Common files

tomcat6-user : Tools to create user instances

tomcat6-docs : Example web applications

tomcat6-examples : Example web applications

To start, stop,  restart and get the server status

Start tomcat server

sudo /etc/init.d/tomcat6 start

Stop tomcat server

sudo /etc/init.d/tomcat6 stop

Restart tomcat server

sudo /etc/init.d/tomcat6 restart

Get tomcat server status

sudo /etc/init.d/tomcat6 status

After installation type http://localhost:8080  or http://serverip:8080/examples/servlets/ in your browser.Now you should see tomcat welcome page

* To enable admin web based features add the following lines to your /etc/tomcat6/tomcat-user.xml

<role rolename="manager"/>
<role rolename="admin"/>
<user name="admin" password="secret_password" roles="manager,admin"/>

* you should be able to see your manage page here http://your_ip_goes_here:8080/manager/html

* log in with the name and password you just set in /etc/tomcat6/tomcat-user.xml

* ls /var/lib/tomcat6 directory.

* you should see these directories conf, logs, webapps, work

* webapps is where your servlets will go ( or at least a xml file that points to them )

* as a test download this war file

* then use the tomcat management page and select war file to deploy ( in teh deploy section) to upload this file to your server

* optionally just wget directly to the webapps folder

* tomcat should recognize the war file and expand it with everything you need

* browse to http://serverip:8080/SimpleServlet/

Change tomcat server to run on port 80

If you want to Change tomcat server to run on port 80 follow this procedure

You need to edit the /etc/tomcat6/server.xml file

nano /etc/tomcat6/server.xml

Now replace the part that says Connector port=”8080? with Connector port=”80?

Save and exit the file

Restart tomcat server with the following command

sudo /etc/init.d/tomcat6 restart

Option Icon 505 under Ubuntu 9.04

Recently I received a new Option Icon 505 USB HSPA adapter through a project I am currently working on. I was quite excited (in a sad way) to get it working with my Linux setup as it is a much more competent piece of kit than the telco provided Huawei units that mobile broadband customers in the UK are given (up until this point a friend of mine had been lending me his Huawei E160G). As I plan on trialling various operators and their services it was clear that I needed to get my hands on a new adapter that was:

a) Unlocked

b) Had receive diversity

c) Had support for Class 10 HSPA and beyond

d) Was supported by Linux

At first glance the Option Icon 505 looked like the perfect choice and Option themselves list the device as Linux compatible. I soon learned that it isn’t quite as simple as that however…

So, I got the item home, installed a SIM & plugged it into my fully updated Ubuntu 9.04 (Kernel 2.6.28-15) machine. Having been spoilt by newer Linux releases and the fantastic updates with the Red Hat sponsored NetworkManager I was expecting a slick driver install, wizard popup, and subsequent quick dial-up to the net. All fine in theory, but things don’t always go to plan.

The first thing that you’ll know if you’re in any way acquainted with mobile broadband on Linux is that most adapters come with a delightful false CD or Mass Storage partition which, as you would expect, appears as a CD or USB drive in Windows Explorer. Yes, Windows. The logic behind this is relatively sane – to negate the need for an actual driver CD to install the modem, because the stick itself acts as a disk in the first instance. Also, early modems took the opportunity to include a microSD storage slot so you could (in theory) use the stick as a combo pendrive & modem but this idea didn’t really catch on.

  • You plug the device in and an autorun popup appears
  • You agree to run the setup program suggested
  • The setup launches, installs the relevant software, and flicks the device over into modem mode
  • Windows looks around for some drivers, and since it’s just had them installed it magically finds and installs the relevant modem ports

The initial problem here is that Linux doesn’t autorun CDs for security, and that the false CD or Mass Storage partition actually doesn’t include any installable driver package for Linux in any case, which is not surprising given that vendors would be expected to support every variant of the OS known to man. No problem, there are usually plenty of drivers in the kernel itself, and if not, we can probably locate some of our own and compile those. Unfortunately, the side effect of presenting a faux device to any operating system is that the device needs to be sent a signal to flip itself back into modem mode since Linux in particular will match up the device, find the relevant module, and claim it to act in whatever way it thinks it should. This of course prevents any other interaction occurring between the device and the correct driver. Enough of the theory, lets take a peek at what happens when we actually plug the Icon in. Here’s the output of dmesg:

[ 1538.245056] usb 2-1: new high speed USB device using ehci_hcd and address 8
[ 1538.377935] usb 2-1: configuration #1 chosen from 1 choice
[ 1538.393133] scsi15 : SCSI emulation for USB Mass Storage devices
[ 1538.393493] usb-storage: device found at 8
[ 1538.393499] usb-storage: waiting for device to settle before scanning
[ 1543.393577] usb-storage: device scan complete
[ 1543.394575] scsi 15:0:0:0: CD-ROM            ZCOPTION Icon 505         1.00 PQ: 0 ANSI: 4
[ 1543.400526] sr1: scsi-1 drive
[ 1543.400778] sr 15:0:0:0: Attached scsi CD-ROM sr1
[ 1543.400928] sr 15:0:0:0: Attached scsi generic sg2 type 5
[ 1543.613518] sr 15:0:0:0: [sr1] Unhandled error code
[ 1543.613528] sr 15:0:0:0: [sr1] Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 1543.613537] end_request: I/O error, dev sr1, sector 32
[ 1543.613548] Buffer I/O error on device sr1, logical block 32
[ 1543.613558] Buffer I/O error on device sr1, logical block 33
[ 1543.613566] Buffer I/O error on device sr1, logical block 34
[ 1543.613573] Buffer I/O error on device sr1, logical block 35
[ 1543.613579] Buffer I/O error on device sr1, logical block 36
[ 1543.613586] Buffer I/O error on device sr1, logical block 37
[ 1543.613593] Buffer I/O error on device sr1, logical block 38
[ 1543.613600] Buffer I/O error on device sr1, logical block 39
[ 1543.613612] Buffer I/O error on device sr1, logical block 40
[ 1543.613619] Buffer I/O error on device sr1, logical block 41
[ 1543.784057] usb 2-1: reset high speed USB device using ehci_hcd and address 8
[ 1543.937639] sr1: CDROM (ioctl) error, command: Get event status notification 4a 01 00 00 10 00 00 00 08 00
[ 1543.937673] sr: Sense Key : No Sense [current]
[ 1543.937683] sr: Add. Sense: No additional sense information
[ 1543.991049] usb 2-1: USB disconnect, address 8
[ 1544.924082] scsi 15:0:0:0: rejecting I/O to dead device
[ 1550.324178] usb 2-1: new high speed USB device using ehci_hcd and address 9

Ugh. Great. So it gets picked up erroneously as a CD Drive, spits out a load of read errors because it won’t play nice with the CD device driver under Linux, resets itself, and the cycle continues (trust me, this will loop). At this point you may fancy reading the official Option response to this issue instead of my guide, which is described in full within the Ozerocdoff readme file, and is…

reproduced here »

Job 1 – I’m a modem, honest

USB Modeswitch used to be the undisputed king of flipping devices back into modem mode (the computing equivalent of a slap & shake) but it doesn’t work at all reliably with Option devices. Instead, Option released their own tool for this called rezero. Unfortunately rezero turned out to be pretty unreliable and so Ozerocdoff was born. Catchy. This enumerated CD mode is often referred to as ZeroCD you see, as some ironic reference to the fact that under Windows it requires ‘Zero’ configuration.

Ozerocdoff jumps in when it sees the modem, and prevents the USB Mass Storage module from claiming the device. It recognises the modem by virtue of the vendor and product ID, which you can retrieve by issuing the command lsusb. Note that if you are using a Linux machine that doesn’t play nice with this particular adapter you may need to repeatedly issue to the command to catch the system before it resets the device. Alternatively you get get the required info from Device Manager in Windows.

Bus 002 Device 040: ID 0af0:d055 Option

The first job therefore is to download Ozerocdoff. Once downloaded, place the file somewhere you can easily access it, like the desktop.

1. Switch to the terminal

2. Change directories to the desktop – cd Desktop

3. Extract the file you just downloaded – tar zxf udev.tar.gz

4. Change to the newly extracted directory – cd udev

5. Compile – sudo make

6. Install – sudo install

I, and many others have had issues compiling.

a) You need of course to make sure you have a compiler installed – build-essential

b)You need the kernel headers appropriate to your system. Issue uname -r and make a note of the output. Replace that command in the following with the output given – sudo apt-get install linux-headers-`uname -r`

c) You also need the USB headers, which can be found in libusb-dev

If you see errors similar to warning: implicit declaration of function then you’re affected by step c in particular.

A successful install should look something like the following:

richard@holly-jaunty:~/Desktop/udev$ sudo make
cc -c ozerocdoff.c -Wall -O
ozerocdoff.c: In function ‘main’:
ozerocdoff.c:243: warning: ‘usb_dev’ may be used uninitialised in this function
cc -l usb -o ozerocdoff ozerocdoff.o
richard@holly-jaunty:~/Desktop/udev$ sudo make install
install -d /usr/sbin
install -d /etc/udev/rules.d
install ozerocdoff /usr/sbin
cp hso.udev /etc/udev/rules.d/51-hso-udev.rules
install -d /usr/share/hal/fdi/preprobe/20thirdparty
cp 10-wwan-hso-preprobe.fdi /usr/share/hal/fdi/preprobe/20thirdparty
install -d /usr/share/hal/fdi/information/20thirdparty
cp 10-wwan-quirk.fdi /usr/share/hal/fdi/information/20thirdparty
install -d /usr/lib/hal/scripts/
install hal-serial-hsotype /usr/lib/hal/scripts/
install -d /etc
install osetsuspend /usr/sbin
cp hso-suspend.conf /etc

Also, now is a good time to check that your user is in the dialout group – grep dialout /etc/group dialout

Now, the Icon 505 is actually too new to be included by default in the list of devices that Ozerocdoff will act on behalf of, so we do need to tell it is how to identify our adapter. This is where the info gathered with lsusb comes in.

In the current version of Ozerocdoff, the file that we need to edit is called /etc/udev/rules.d/51-hso-udev.rules but it looks like this is incremented for every new version of the software. An easy way to find out the filename is to take a peek at the output given when you issued sudo make install during the installation process.

1. Switch to the terminal

2. sudo gedit /etc/udev/rules.d/51-hso-udev.rules

3. Under “New Syntax” you will see ten or more almost identical lines of code each referencing a different device (idProduct), albeit from the same vendor (idVendor). Copy and paste the last statement and alter it to suit the product ID for you device. Mine looks like the following:
ATTRS{idVendor}==”0af0″, ATTRS{idProduct}==”d055″, RUN+=”/usr/sbin/ozerocdoff -wi 0x%s{idProduct}”

4. Under “Old Syntax” you will see a similar arrangement, the only difference being a more obfuscated set of commands. Again, copy and paste the last statement and alter the product ID. Mine looks like the following:
SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”0af0″, SYSFS{idProduct}==”d055″, SYSFS{bDeviceClass}==”00″, RUN+=”/usr/sbin/ozerocdoff -wi 0x%s{idProduct}”

5. Save and exit the file

6. Refresh the udev rules, so  that the next time you plug in a device, it will read the freshly created rules and thus act upon them: sudo udevadm control –reload-rules

7. Plug in your Icon. Give the system ~20secs and then check the output of dmesg. You should notice that the device no longer gets claimed as scsi 15:0:0:0: CD-ROM            ZCOPTION Icon 505         1.00 PQ: 0 ANSI: 4

8. Although in all likelyhood nothing else will step in to fill the void if you’re using another member of the Option family it may be that the Option driver steps in to try and cater to the device, but since the Icon 505 and others use a new IP only architecture it simply won’t work properly. We need to blacklist the Option driver by editing a configuration file. Issue sudo gedit /etc/modprobe.d/blacklist.conf and append the following:
# Blacklist the option modem driver. This will allow the HSO driver (when installed) to step in and provide functionality to the Icon 505 amongst others
blacklist option

Job 2 – Drivers please

1. At this point Ozerocdoff should be working and preventing  the Icon from registering itself as a CD Device. However, it still needs some drivers in order to function. The drivers that cover these new WWAN devices are called HSO – High Speed Option, and have a new architecture to allow use of fast HSPA adapters. You can download the newest version (currently 1.12) here.

2. Download or move the archive to the desktop and extract it using tar zxf hso-1.12.tar.gz

3. Move into the new directory using cd hso_26-v1.12

4. Compile the driver using sudo make

5. Install the driver using sudo make install

6. Plug in your adapter and you should be up and running. As with any issues, I would heartily recommend a reboot or two, and a double-check of all steps before putting it down to a bad effort. As I was putting together the above steps I was trying it on my fresh 9.04 box and scratching my head as  to why I was having no luck. Turns out I was using d055 as the product ID instead of d050! A successful installation should push out a dmesg log like this:

[  111.852198] usb 2-2: new high speed USB device using ehci_hcd and address 4
[  111.986505] usb 2-2: configuration #1 chosen from 1 choice
[  113.194548] usb 2-2: USB disconnect, address 4
[  113.468210] usb 2-2: new high speed USB device using ehci_hcd and address 5
[  113.602299] usb 2-2: configuration #1 chosen from 1 choice
[  114.293835] Initializing USB Mass Storage driver…
[  114.294067] usbcore: registered new interface driver usb-storage
[  114.294074] USB Mass Storage support registered.
[  114.327312] hso: /home/richard/Desktop/hso_26-v1.12/hso.c: 1.12-Option Option Wireless
[  114.330282] hso0: Disabled Privacy Extensions
[  114.331628] usbcore: registered new interface driver hso

How to Installing Apache 2.2.11 with Weblogic 10.3 on 64 bit Ubuntu 9.04

To install Apache 2.2.11 on Ubuntu 9.04 64 bit and make it work with Weblogic 10.3 please follow the below steps. The post walks through the steps that I followed, the problems that I faced and the solutions ( er..hacks) to get them resolved.

Installing Apache

  • Is simple do

sudo apt-get install apache2

If you want to build it from sources then follow these steps.

  • Once you have installed apache2 then the installation happens at the following locations in Ubuntu

Apache config files are in /etc/apache
Apache log files are in /var/log/apache
Apache libs are in /usr/lib/apache
Other files can be in /usr/share/apache, /var/lib/apache
executables in /usr/sbin apache and apache2ctl

  • Now to start apache execute the following

stev@stev-laptop:/usr/sbin$ sudo apache2ctl start

  • Note that the server is started as a root, else you might get the following error

(13)Permission denied: make_sock: could not bind to address
no listening sockets available, shutting down
Unable to open logs

You should be able to access the default page on http://localhost now and see It Works!

Now, Integrating with Weblogic

  • Download the apache plugins for weblogic 10.3 from the following location

  • Unzip the contents and select the file from the location


  • This file needs to be loaded the following location


  • to test whether the file is valid or not do ldd

stev@stev-laptop:/usr/lib/apache2/modules$ ldd =>  (0×00007fff02ffe000) => /usr/lib/ (0×00007f5cfaaff000) => /lib/ (0×00007f5cfa87a000) => /lib/ (0×00007f5cfa661000) => /lib/ (0×00007f5cfa2ef000)
/lib64/ (0×00007f5cfafc5000)

  • You might notice that some file like in my case => was not found!

-bash-3.00$ ldd => not found => /lib64/tls/ (0×0000002a9572f000) => /lib64/ (0×0000002a958b5000) => /lib64/tls/ (0×0000002a959c3000)
/lib64/ (0×000000552aaaa000)

  • Goto the synaptic package manager, search and install this file.
  • Now create a weblogic.load file with the following contents

LoadModule weblogic_module /usr/lib/apache2/modules/

  • and put it at the following location


  • You can also create a weblogic.conf file with the following contents at the same location

<Location /medrec>
SetHandler weblogic-handler
WebLogicPort 7011

This would help in redirecting a request like http://localhost/medrec to the weblogic server running on and at 7011 port with the application name medrec.

  • Restart Apache

stev@stev-laptop:/usr/sbin$ sudo apache2ctl restart

  • Check whether the weblogic_module has been loaded successfully or not

stev@stev-laptop:/usr/sbin$ apache2 -t -D DUMP_MODULES
apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_worker_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgid_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
setenvif_module (shared)
status_module (shared)
weblogic_module (shared)

  • If you see the weblogic_module loaded fine then you have configured it correctly and can now access the application at


  • To test whether the apache2.conf file is correct or not you can use

stev@stev-laptop:/usr/sbin$ apache2 -t
apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName
Syntax OK

Other Potential Problem(s)

  • You may encounter the problem bad user name ${APACHE_RUN_USER}

this is because the value of ${APACHE_RUN_USER} is not getting picked up. Ideally it should be picked up from /etc/apache2/envvars

which has the following entries

# envvars – default environment variables for apache2ctl

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/

However, still in your case if these values are not picked up then goto the /etc/apache2/apache2.conf file and make the following changes

# These need to be set in /etc/apache2/envvars
User www-data
Group www-data

  • The weblogic.load file is not read for some reason and hence the weblogic_module is not loaded

Make an entry in the httpd.conf file at the following location


and enter the LoadModule and other configuration data in this file

LoadModule weblogic_module /usr/lib/apache2/modules/

<Location /medrec>
SetHandler weblogic-handler
WebLogicPort 7011

There is an entry in the apache2.conf file to include the httpd.conf file, hence the changes of httpd.conf would get loaded

# Include all the user configurations:
Include /etc/apache2/httpd.conf

Author :  Vikas Hazrati

Vikas Hazrati

PHP – Ubuntu 9.04 + PHP5 + GD2

It all started when I decided to optimize image slicing algorithm for a new feature on UMapper – and since GD is quite RAM-intensive, I needed to check actual memory consumption, and the obvious choice to do so was PHP’s memory_get_usage() function. However, it failed to produce accurate results – it seemed like images loaded into memory weren’t accounted by the function (RAM was still used :) ).
As it turned out, whoever prepared official php5-gd package, compiles against original GD, and not using PHP5 bundled version of the library. I actually wasn’t aware about the fork, but here is explanation from GD Official Site:

The PHP version of gd offers features similar to and sometimes in addition to those included in the latest version of gd found here as well as many bug fixes not present in the latest GD release. If you are working with PHP, using the built-in gd of PHP 4.3.0 or better is recommended.

We are working to merge the changes done in the PHP GD in the normal GD library.

Well, I was pretty sure that unexpected behavior was caused by using original GD library instead of bundled one. So I decided to remove php5-gd package, recompile php5 from sources, and install updated GD package – which is exactly what gets bundled with PHP5 on other distributions.

Google is my friend, so here is a walkthrough:

# Install build tools, debian helpers and fakeroot
apt-get install build-essential debhelper fakeroot
# Get PHP source (it should go into /usr/src)
cd /usr/src
apt-get source php5
# Install all packages required to build PHP5
apt-get build-dep php5

#Now what we need is to update compile options,
# so we need to edit debian/rules file:
cd php5-5.2.6.dfsg.1
vim debian/rules
# locate the line having “–with-gd=shared,/usr –enable-gd-native-ttf \”
# replace with “–with-gd=shared –enable-gd-native-ttf \”
# that’s remove reference to /usr so that bundled library is used

# compile (drink some coffee, walk you dog, see the latest House episode)
dpkg-buildpackage -rfakeroot

# install the new php5-gd package
cd ..
dpkg -i php5-gd_5.2.6.dfsg.1-3ubuntu4.2_i386.deb

# finally restart apache
/etc/init.d/apache2 restart

That’s it – you should be able to see «bundled» near the GD version in the phpinfo() output. Well, that’s not the only gain – it solves problem with memory_get_usage() as well :)

Now, once I had memory_get_usage() working correctly, back to optimization..