File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Help please ;-( Apache2 - Tomcat5 integration on FeeBSD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Help please ;-( Apache2 - Tomcat5 integration on FeeBSD" Watch "Help please ;-( Apache2 - Tomcat5 integration on FeeBSD" New topic
Author

Help please ;-( Apache2 - Tomcat5 integration on FeeBSD

tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
Hi All!

I have problems integrating Apache2 and Tomcat5 on a FreeBSD server and I'ld like to confess that server administration is a very weak spot for me, as I've always delt with code rather than administration. However I must solve this puzzle eventually.

So I set out armed with Professional Apache Tomcat 5 from Wrox and it's only marginally helpfull in my case. I'll be the first to admit that I might be just not too sharp with it.

I've tried searching for info on the topic that's FreeBSD specific but had limited luck so far.

I've you have anything to share I thank in advance.

This is what I've done (as best as I can recall right
now)

-----------------

1. - in server.xml I just looked at the AJP Connector
and it was/is set to port 8009

------------------

2. - created the workers2.properties file and it looks
like this:

# workers2.properties set up by Tomasz Brymora
# tomekpilot@yahoo.com
# 4-06-2005

# settings for Logger of type Apache2
[logger.apache2]
file=/usr/local/etc/apache2/logs/error.log
level=INFO
debug=1

# Provide the basic config needed
[config]
file=/usr/local/etc/apache2/workers2.properties
debug=0

# Define a socket communication channel
[channel.socket:cinnamonbaycoffee.com:8009]
host=cinnamonbaycoffee.com
port=8009
tomcatId=myTomcat

# Shared Memory file settings
[shm]
file=/usr/local/etc/apache2/jk2.shm
size=1000000

# Define a tomcat worker which will use the
communication channel defned
# in the previous step
[ajp13:cinnamonbaycoffee.com:8009]
channel=channel.socket:myTomcat

# Map the Tomcat jsp-examples webapp to the Web server
uri space
[uri:/jsp-examples/*]
info=mapping the jsp-examples context of Tomcat

------------------

3. - in httpd.conf uncommented the line for LoadModule
jk2_module so it can load

------------------

4. - edited the jk2.properties file:

## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE
TOMCAT IS STOPED
## WHEN YOU EDIT THE FILE.

## COMMENTS WILL BE _LOST_

## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.

# Set the desired handler list
# handler.list=apr,request,channelJni
#
# Override the default port for the socketChannel
# changes by Tomasz 4.06.05
channelSocket.address=cinnamonbaycoffee.com
channelSocket.port=8009
channelSocket.serverTimeout=600
channelSocket.maxThreads=50

# Default:
# channelUnix.file=${jkHome}/work/jk2.socket
# Just to check if the the config is working
# shm.file=${jkHome}/work/jk2.shm

# In order to enable jni use any channelJni directive
# channelJni.disabled = 0
# And one of the following directives:

# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so

# If set to inprocess the mod_jk2 will Register
natives itself
# This will enable the starting of the Tomcat from
mod_jk2
# apr.jniModeSo=inprocess

------------------

5. - stoped and started Tomcat, stoped and started
apache2

------------------

6. - tested it in the browser but I could not get the
JSP examples page without specifying port 8080 in url

------------------

7. - this morning: re-created workers2.properties
based on the sample in the directory:
workers.properties.sample, this time it looks like
that:

# workers2.properties set up by Tomasz Brymora
# tomekpilot@yahoo.com
# try 2 - 4-06-2005

# this file based on workers.properties.sample

worker.list=cinnamonbaycoffee.com

worker.cinnamonbaycoffee.com.port=8009
worker.cinnamonbaycoffee.com.host=cinnamonbaycoffee.com
worker.cinnamonbaycoffee.com.type=ajp13
worker.cinnamonbaycoffee.com.lbfactor=1

-------------

8. - restarted Tomcat, restarted Apache

-------------

9. - discovered the mod_jk.properties file, looked at
it, and created mod_jk2.properties looking like this:

# created by Tomasz Brymorat tomekpilot@yahoo.com
# try 1
# 04.06.2004


# Replace jsp-hostname with the hostname of your JSP
server, as
# specified in workers.properties.
#
IfModule mod_jk2.c
JkWorkersFile
/usr/local/etc/apache2/workers2.properties
JkLogFile logs/jk.log
JkLogLevel warn

# Sample JkMounts. Replace these with the
paths you would
# like to mount from your JSP server.
JkMount /*.jsp cinnamonbaycoffee.com
JkMount /servlet/* cinnamonbaycoffee.com
JkMount /examples/* cinnamonbaycoffee.com
/IfModule

------------

10. - restarted Tomcat, restarted Apache, no luck,
still must specify port 8080 in the url to see the JSP
samples page

------------

11. - decided to mod the mod_jk.properties file
itself:

# created by Tomasz Brymorat tomekpilot@yahoo.com
# try 1

# did this after trying to create mod_jk2.conf

# 04.06.2004


# Replace jsp-hostname with the hostname of your JSP
server, as
# specified in workers.properties.
#
IfModule mod_jk2.c
JkWorkersFile
/usr/local/etc/apache2/workers2.properties
JkLogFile logs/jk.log
JkLogLevel warn

# Sample JkMounts. Replace these with the
paths you would
# like to mount from your JSP server.
JkMount /*.jsp cinnamonbaycoffee.com
JkMount /servlet/* cinnamonbaycoffee.com
JkMount /examples/* cinnamonbaycoffee.com
/IfModule


# Tomaszh code continued

IfModule mod_jk.c
JkWorkersFile
/usr/local/etc/apache2/workers2.properties
JkLogFile logs/jk.log
JkLogLevel warn

# Jk Mounts
JkMount /*.jsp cinnamonbaycoffee.com
JkMount /servlet/* cinnamonbaycoffee.com
JkMount /examples/* cinnamonbaycoffee.com
/IfModule

-----------

12. - restarted Tomcat and Apache respectively, still
no luck with the url, still get 404 error without
specifying port 8080 in the url to view the JSP
samples page

-----------

now, all the original unmded files are there, just
maked 'name-original'

... any ideas from this vantage point?

well, I really appreciate your help.

Tomasz
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Let try a couple of things.

1. What is the URL that you are using to access the JSP/Servlet examples?

2. Verify that Apache is up and running. Try accessing the Apache default webpage i.e. http://localhost.

3. I believe you already verified that TOMCAT is up and running.

4. Add the following:


Give it try and let us know how it turns out.
tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
... should I change 'tomcatId=myTomcat' to 'tomcatId=cinnamonbaycoffee.com' in workers2.properties by any chance? here's what's there now:

# Define a socket communication channel
[channel.socket:cinnamonbaycoffee.com:8009]
host=cinnamonbaycoffee.com
port=8009
tomcatId=myTomcat

# Shared Memory file settings
[shm]
file=/usr/local/etc/apache2/jk2.shm
size=1000000

# Define a tomcat worker which will use the
communication channel defned
# in the previous step
[ajp13:cinnamonbaycoffee.com:8009]
channel=channel.socket:myTomcat

this works fine:http://www.cinnamonbaycoffee.com:8080/

apache is running fine (so i think anyway)


I'll do this part a little later, have to bail for the moment:

JkMount /webapps/* cinnamonbaycoffee.com
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I would go back to your original specs from your first post.

Did you verify that the mod_jk2.so is in the /module/mod_jk2.so directory?

3. - in httpd.conf uncommented the line for LoadModule
jk2_module so it can load
tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
update: the connector works now at least.

we have the mod_jk doing the work instead of mod_jk2, but it seems to work.

we also changed/added JkMount settings in virtual_hosts file in apache2

next questions I have how do I set up the work environment so I don't have to edit .xml files manually every time I add a .jsp file? I'm afraid some initial editing will be required, but I'd like to set it up in the easiest way possible.

well, yes, this is how much catchup learning I must do in the admin arena:


root cause
java.io.FileNotFoundException: /usr/local/jakarta-tomcat5.0/work/Catalina/localhost/jsp-examples/org/apache/jsp/Form_jsp.java (No such file or directory)

... I'm tryin to run my own test .jsp file and the 500 error shows up, I'm not sure what it REALLY looking at.

thanks
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Can you elaborate?

next questions I have how do I set up the work environment so I don't have to edit .xml files manually every time I add a .jsp file?
tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
... well, this is what I do when I work in another hosting enviroment, I simply create my .jsp file, then drop it in wherever, literally, (say next to my index.html file for instance) and it runs. I never have to touch anything elese, for all proctical reasons and pursposes I don't ever have to meet Mr. (or Mrs, MS? ) web.xml file.

In the case of the puzzle I brought here it does't work that way. Say the default jsp & servlet examples wtha come with Tomcat are working ok, but if just drop a .jsp file and try to run it I get the avove 500 error

... it's back to scratching my head now.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
What path/directory are you "dropping" your JSP file?

And if you could post the contents of the JSP file, that might be helpfull.
tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
from the browser's perspective I'm trying to run:

http://cinnamonbaycoffee.com/jsp/Form.jsp

on the server the things sits in:

/usr/local/jakarta-tomcat5.0/webapps/ROOT/jsp/Form.jsp

it turns out that after all the config changes, webapps directory is where the browser goes to.

How the other hosting provider had the stuff configured, I don't know, never had root access to my acount on that one.

T
tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
... hm, I think I found out that the other place is using Resin. Oh well,

New question, regarding the Tomcat Manager.
I was able to enable this one fine and now:

in the ROOT directory I have 'jsp' directory with Form.jsp in it.

I'm trying to deploy it through the manager


I've created a Form.xml file for it:

<Context path="/jsp" docBase="${catalina.home}/server/webapps/jsp"<br /> debug="0" privileged="true">
< !-- some comments -->
<ResourceLink name="users" global="UserDatabase"<br /> type="org.apache.catalina.UserDatabase"/>

</Context>

... I'm entering:

Context Path (optional):
XML Configuration file URL:
WAR or Directory URL:


the error the manager spits out is:
FAIL - Encountered exception java.net.MalformedURLException: no protocol: jsp/Form.xml

... I'm thinking I'm getting closer I think, but is it ever slow!

T
tomasz brymora
Greenhorn

Joined: May 31, 2004
Posts: 22
...well, the saga continues, the connectro seems to be working but now I'm not able to compile/run a jsp file quiet yet. the closest i get to it is a 505 error.

I went and try to actually get a better view of what works and what doesn't with the present configuration.

1 - httpd.conf loads mod_jk.c (or it's supposed according to what I see, not mod_jk2.c though)
2 - one of the last lines in httpd.conf specifies a workers2.properties in apache2 dir. (before it had one in jakarta-tomcat5.0 dir.

3 - in apache2/virtual_hosts there's a file named www.cinnamonbaycoffee.com.conf that specifies JkMount(s) that seems to do the trick as far as being able to run/view, say /jsp-examples/ that come with Tomcat

when I comment out those JkMount lines, I cant' see files/directories, [uri: ****] mappings in workers2.properties seem to make no difference, not JkMount(s) in mod_jk.conf file.

4 in jakarta-tomcat5.0/conf I see jk2.properties file but no jk.properties file does it matter?

this is what the files look like:

JK2.PROPERTIES:

channelSocket.address=cinnamonbaycoffee.com
channelSocket.port=8009
channelSocket.serverTimeout=600
channelSocket.maxThreads=50

VIRTUAL_HOSTS/WWW.CINNAMONBAYCOFFEE.COM.CONF:
ServerName www.cinnamonbaycoffee.com
ServerAlias cinnamonbaycoffee.com

Documentroot "/usr/local/www/cinnamonbaycoffee.com/www"
DirectoryIndex index.php index.php3 index.html index.cgi index.htm home.htm

ErrorLog /var/www/cinnamonbaycoffee.com/www/error_log
CustomLog /var/www/cinnamonbaycoffee.com/www/access_log combined

Alias /stats /usr/local/stats/cinnamonbaycoffee.com/www

# JkMount /usr/local/www/cinnamonbaycoffee.com/www/webapps/* cinnamonbaycoffee
# JkMount /jsp-examples/* cinnamonbaycoffee

APACHE2/mod_jk.conf:

JkWorkersFile /usr/local/etc/apache2/workers2.properties
JkLogFile logs/jk.log
JkLogLevel warn

# Jk Mount
JkMount /jsp-examples/* cinnamonbaycoffee.com

(uncommented JkMount here seems to make no difference though)

APACHE2/workers2.properties:

worker.list=cinnamonbaycoffee
# communications channel
[channel.socket:200.46.204.56:8009
info=Ajp13 forwarding over socket
tomcatId=200.46.204.56:8009

worker.cinnamonbaycoffee.port=8009
worker.cinnamonbaycoffee.host=200.46.204.56
worker.cinnamonbaycoffee.type=ajp13
# worker.cinnamonbaycoffee.lbfactor=1

# uri mappings
[uri:/jsp-examples/*]
info=maping jsp-examples context of Tomcat


- uri mapping seems to have no effect either.

.... sheesh, well, if anybody makes any sense out of that I'd love to find out what's happenng.

Hopefully some other poor bastad wont have to suffer as much next time ;-)

T
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help please ;-( Apache2 - Tomcat5 integration on FeeBSD
 
Similar Threads
Tomcat service terminated unexpectedly (Tomcat5.0.28, apache2.0.54 and mod_jk 1.2.5)
Tomcat 4.1.12 not executing JSP on Sun OS
How to configure tomcat handle jsp files from apache DocumentRoot
File uploading problem
Please help integrating Apache2.0.61 with Tomcat-5.5.15