aspose file tools*
The moose likes General Computing and the fly likes Apache 2 and Tomcat 7 on Ubuntu 10.04 in VirtualBox 4.06xxx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "Apache 2 and Tomcat 7 on Ubuntu 10.04 in VirtualBox 4.06xxx" Watch "Apache 2 and Tomcat 7 on Ubuntu 10.04 in VirtualBox 4.06xxx" New topic
Author

Apache 2 and Tomcat 7 on Ubuntu 10.04 in VirtualBox 4.06xxx

Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Hello,

Thanks for looking at this thread.

I am not able to forward requests from Apache2.2.14 to Tomcat7.0.14 using the following browser address:



I am able to invoke the servlet directly from the Tomcat7.0.14 container using the following browser address:



$CATALINA_HOME is /usr/share/tomcat7
$CATALINA_BASE is /var/lib/tomcat7



I have been working on this problem for hours, and I haven't been able to access Tomcat 7 from Apache 2.

Do you have any ideas where I might look to correct this problem?

Thanks,
Harry
Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
See http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html for more information.
Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Hello,

I'm not really sure if I'm making any progress. I copied my webapplication from /var/lib/tomcat7/webapps to /var/www. I can launch the application from either Apache2.2.14 or from Tomcat7.0.14 with either http://localhost:80/Beer-v1/form.html or http://localhost:8080/Beer-v1/form.html, respectively.

In /var/www/Beer-v1/WEB-INF, I have the web.xml file that defines the servlet:



When I launch the webapplication from Apache2.2.14, I get the following error message:



I have setup httpd.conf
I have setup workers.properties with a worker called ajp13_worker on port 8009
I am using mod_jk.so that was included with apache2 on Ubuntu.

I'm not exactly sure what is going wrong? Any ideas?

Thanks,
Harry Henriques
Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Hello,

I am now able to forward an HTTP/1.1 request from Apache 2.2.14 to Tomcat 7.014 on Ubuntu 10.04 LTS (32-bit) in a VirtualBox 4.0.6r71416 on top of Windows 7 (64-bit):



The DocumentRoot for the default VirtualHost in apache2 is /var/www. In this folder, /var/www/Beer-v1/form.html is the only file (a static HTML page).

It is unnecessary to have WEB-INF/web.xml on the apache2 side.

$TOMCAT_HOME/webapps/Beer-v1/WEB-INF/web.xml is all that is needed to map SelectBeer.do to $TOMCAT_HOME/webapps/Beer-v1/WEB-INF/classes/com/example/web/BeerSelect.class

The following request is forwarded by the mod_jk.so to the tomcat-connector at port 8009 specified in $TOMCAT_HOME/conf/server.xml



I didn't modify $TOMCAT_HOME/conf/server.xml at all.

On the apache2 side, the workers.properties file specifies that worker.ajp13_worker.port=8009

mod_jk.so (1.2.28) is packaged with Apache2.2.14, and is in the /usr/lib/apache2/modules/mod_jk.so folder. I was able to successfully use this binary file without generating my own copy.

I was unable to auto-generate the mod_jk.conf file using the "-jkconf" option at Tomcat 7.0.14 startup. I don't think that it is possible with this version of Tomcat.

I did download tomcat-connectors-1.2.31-src.tar.gz from the tomcat-connectors website. This tarball has a file called httpd-jk.conf that is useful when generating your own mod_jk.conf

apache2 has another example /usr/share/doc/libapache2-mod-jk/httpd_example_apache2.conf

I used both of these examples to implement mod_jk.conf. I put the finished version in /etc/apache2/mods-enabled/mod_jk.conf. This file is Include in /etc/apache2/apache2.conf.

I removed "LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so" from mod_jk.conf. This line is already included in /etc/apache2/mods-enabled/jk.load.

I didn't "Include /usr/lib/apache2/modules/mod_jk.so" in httpd.conf.

I used the apache2 example in /etc/libapache2-mod-jk/workers.properties file. I copied, modified, and saved this file right in this folder.

In a fresh install of apache2, the /etc/apache2/httpd.conf file is empty. I put the following code snippet in this file. This file is Include in /etc/apache2/apache.conf.



There is an entry in /etc/hosts, i.e. 127.0.0.1 localhost.localdomain localhost

ajp13_worker was created in the workers.properties file.

I created a tomcat user in Ubuntu and in the $TOMCAT_HOME directory I executed the following command: sudo chown -R tomcat:tomcat *

This will only work after you create a tomcat user.

I also did this in $CATALINA_HOME.

A useful link is the following: http://www.linuxjournal.com/article/8561

Regards,
Harry Henriques
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apache 2 and Tomcat 7 on Ubuntu 10.04 in VirtualBox 4.06xxx
 
Similar Threads
form.html not displayed
FIRST EXAMPLE NOT WORKING..!!
first program error, something is missing
Head First Sample Code
Problems with the Example from HF Servlets & JSP in Chapter 3