Search ServerWatch
Search ServerWatch
Search ServerWatch



Become a Marketplace Partner

  • Partner With Us















Enabling WebDAV on Apache

Safer Apache Driving with AAA

JBoss: A Robust, But Unpolished App Server

Newest Apache Release Fixes Yet Undisclosed Vulnerability

Weaving Your Way Through the Web Server Scene

ServerWatch > Tutorials

March 7, 2008
Integrating Tomcat with Apache
By Martin Brown

As with other modules, there are two parts to the configuration. The first just tells Apache that the module exists and where to find it using a LoadModule directive. The second part tells the module how to function within the Apache environment. For mod_jk the minimum we need is:

LoadModule jk_module libexec/mod_jk.so

JkWorkersFile /usr/local/apps/jakarta-tomcat-4
      /conf/workers.properties

JkLogFile /usr/local/apache/logs/mod_jk.log

JkLogLevel info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
The JkWorkersFile should point to the location of the file that specifies how mod_jk should connect to the Tomcat service and interact with the various worker processes created by Tomcat.

JkLogFile specifies the location of a log for mod_jk errors and information. JkLogLevel and JkLogStampFormat specify what the log contains and what it looks like.

The Workers File

The Workers file defines the various links between Apache, mod_jk and Tomcat. Essentially, Apache forwards any request for a given URL to the Tomcat service, but we must tell Apache how to identify which Tomcat process to communicate and forward the request.

If you built mod_jk from the source you can find a sample workers.properties file that will work perfectly with the default configuration file for Tomcat in the jk/conf directory. In fact, it's probably worth downloading the connector source code for that file alone!

If you don't want to download the source, then you should be able to get by using the following:

workers.tomcat_home=/usr/local/apps/jakarta-tomcat-4

workers.java_home=/usr/java1.4.1
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
That creates a connector called ajp13 (we'll need that in a minute), which is located on the local machine on port 8009. This is one of the standard ports listened to by Tomcat. You can define as many different connectors as you like, providing of course you have a corresponding Tomcat process listening on the right port.

Forwarding Requests
The final step is to tell Apache which files should be assigned to Tomcat for processing and which of the workers to direct the request to. You do this using the JkMount directive, which effectively mounts a Tomcat worker process to a given file specification. For example, to redirect all requests for files ending in .jsp on this server to the worker identified as ajp13, you would use:

JkMount /*.jsp ajp13
The file specification uses Unix-like wildcard specifications, so we could have specified that all files be forwarded to Tomcat using:

JkMount /* ajp13
Testing it Out
To test out your installation, copy a suitable JSP or servlet into your Web server directory and then try accessing it from a browser. Remember that you must have both Tomcat and Apache running. Assuming everything is working OK then you should get the desired result. If there's an error, you'll need to check one of the various log files for more information. To help you determine which one, look at the error message reported in the browser.

Discuss this article in the ServerWatch discussion forum

Unsure About an Acronym or Term?
Search the ServerWatch Glossary
 

If the error was generated by Tomcat, then you need to check the Tomcat logs in the main Tomcat installation directory. It probably means either there is an error in your JSP or a class on which it relies or there is a problem with accessing the file in question. Because requests are forwarded to Tomcat immediately, a missing file will be reported by Tomcat, not Apache.

If it's an error generated by Apache, check the Apache logs and the mod_jk logs. If the error is reported in the mod_jk log, then it probably points to a problem with the configuration somewhere.

If you get an Internal Server Error from Apache, then check whether Tomcat is running before digging any deeper.

Original date of publication, 05/03/2003

Go to page 1  2  


Discuss this article
Tools:
Add serverwatch.com to your favorites
Add serverwatch.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x

Tutorials Archives




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Tripwire Whitepaper: Seven Practical Steps to Mitigate Virtualization Security Risks
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES