<< Previous | Home

Happy New Year

Happy New Year 2009

Tomcat 6.0.18, Apache 2.2.9, proxy_ajp on Ubuntu 8.10: Almost Trivial...

... after four hours of documentation re-reading.

[Update Tue Dec 23 15:30:20 CST 2008] The above line was written two days ago when I moved this blog away from a dying PC. Regular readers might have noticed outages of this blog for stretches of several hours at a time and during the evening hours. The whole machine would lock up while the disk light is a solid on, presumably trying to read something off the disk.

This is the second time a PC has died at home. If you remember, gao-2002 went out of commission only 23 days ago. And now gao-2006 is gone. You've seen gao-2006 mentioned here, here, here, and here.

Luckily, I was able to save all the data from the dying PC before it finally would get a kernel panic during the boot up process. I felt that I was this close to writing a different blog entry that begins: "I'm an idiot and I lost all data in this blog..."


Are your data backed up? Now would be a good time to implement your backup strategy.


With the backed up data, I was able to setup this blog on gao-2009 within four hours, most of it spent on one task. Here's entire process on this Ubuntu 8.10 machine:

  • Install sun-java6-jdk from Synaptic Package Manager
  • Install apache2 from Synaptic Package Manager
  • Install tomcat6 from Synaptic Package Manager
  • Deploy my blog at /var/lib/tomcat6/webapp/blog
  • Connecting apache2 to tomcat6

The first four steps are trivial. I did the first three prior to the move. Step 4 took minutes. Step 5 is also trivial, but I didn't know it when I started. What tripped me up is Google. Most of the search results leads to outdated information. And I spent a number of hours following the wrong leads, most of them about mod_jk, which I custom compiled in the early days of this blog.

It finally downed on me that perhaps I should read the documentations. And what a good idea what was. All I need to know is in the documentations:

The gist of the documentation can be distilled to three sentences: Apache 2.2.9 includes mod_proxy_ajp support. Tomcat 6.0.18 is configured with an AJP connector by default. All I need to do is to enable mod_proxy_ajp and then tell it where my webapp is.

To enable mod_proxy_ajp I used the command:

[root@gao-2009] # a2enmod mod_proxy_ajp

To tell Apache 2.2.9 where my webapp is I added /etc/apache2/conf.d/proxy_ajp with the following content:

ProxyPass /blog ajp://localhost:8009/blog
ProxyPassReverse /blog ajp://localhost:8009/blog

<Proxy /blog>
  Order deny,allow
  Allow from all
</Proxy>

It turns out I also need to edit /etc/apache2/mods-enabled/proxy.conf to change a line that says Deny from all into Allow from all. Without this change, noone can access the blog and I get error message that reads:

... client denied by server configuration: proxy:ajp://localhost:8009/...

That's all there is to it.

Wednesday Java Quiz

(Mark Volkmann suggested this quiz.)

Q: Will the following Java source compile, run without exceptions?

import java.util.SortedMap; 
import java.util.TreeMap; 
 
public class Main { 
    public static void main(String[] args) { 
        SortedMap sm = new TreeMap(); 
        sm.put("one", 1); 
        sm.put(2, "two"); 
 
        System.out.println("value for one is " + sm.get("one")); 
        System.out.println("value for 2 is " + sm.get(2)); 
    } 
}

Strict rules: No actually running the Java compiler.