aspose file tools*
The moose likes Tomcat and the fly likes tomcat6 and apache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat6 and apache" Watch "tomcat6 and apache" New topic
Author

tomcat6 and apache

Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
I am trying to connect tomcat to apache so I can use jsp pages on apache.

I followed the directions
downloaded the apache jk_module
but the configurations for it so apache uses it when started up.
uncommented the connector line in tomcat
and setup the work.properties file for tomcat.

I can get to the tomcat examples the normal way http://localhost:8080/examples or http://my.domain.com:8080/examples
But when I try http://my.domain.com/examples it is not forwarding port 8080 to port 80 ?

I don't want to portforward all of 8080 to 80 just want to use the connector for it. I think it runs in port 8009 for ajp3

Any help would be great.
If you need any more info please ask as I will provide the files as needed.

Thanks it would be great to get this working.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
What operation system, Tomcat, Apache Tomcat Connector versions do you run? What message do you get from http://my.domain.com/examples ? Post content of configuration files like work.properties, server.xml and etc
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

If you don't put an explicit port number on an http: URL, the default port number of 80 is used by your web browser. Which would send your request to Apache httpd. The mod_jk connector reroutes the request from httpd to Tomcat through Tomcat's port number 8009 using a custom protocol which basically wraps the HTTP protocol. Apache httpd doesn't talk to Tomcat port 8080, nor should anyone else unless they intend to bypass httpd and talk to Tomcat directly without using mod_jk.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
this is the server.xml
this was under /etc/tomcat6 directory




this is the workers.properties file
I put it under the /etc/tomcat6/conf directory



I have no firewalls running.
I did a portscan and it says port 8009 is on so ajp3 is running As well as the apache2 webserver on port 80 and tomcat6 on port 8080
I am on ubuntu it is the newest version.
So you can pretty much assume the connector is the most recent I cann't remember what I downloaded but it was the most recent since a few weeks ago.
for the apache2 and tomcat I just used sudo apt-get install package so it is the most recent I believe.


When I go to the http://localhost:8080/examples or http://domain.name.com:8080/examples It displays fine but if I take away the :8080 and just use the default 80 port I would think apache would be forwarded the examples/...etc

I know you could accomplish this by just forwarding port 8080 to port 80 but I should beable to do it thru the connector / ajp3 thing.
Their is numerous directions on google for setting this up but I just cann't seem to find ones that work for me.

Thanks for any help am I missing anything
I would like to beable to run jsp pages in apache.
I have already installed php in apache works great.







Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
as for the question on what error it gives when going to http://localhost/examples it gives a page not found error
So some how it is not forwarding requests from/to 8080 80
If their is any more info you need let me know.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:
this is the workers.properties file
I put it under the /etc/tomcat6/conf directory


How does Apache know about this file?
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
I put this file in the etc/apache2/mods-available/
file named jspconnector.load
this is how apache knows where the workers.property file is in tomcat6.





So the only thing I can think of is maybe In need to have the JKMount as /examples/servlets-examples ajp3 instead of just something like servlets-examples ajp13

Don't know whats going on
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:
So the only thing I can think of is maybe In need to have the JKMount as /examples/servlets-examples ajp3 instead of just something like servlets-examples ajp13


You are correct. Perhaps even this would work in your case


JkMount /examples ajp13
JkMount /examples/* ajp13


Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204

I tried what you said about the examples but that didn't work.
I can access examples page thru http://localhost:8080/examples/ but not http://localhost/examples/ yet.
I did restart the apache2 server after modifying the file.

Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:
I tried what you said about the examples but that didn't work.


"Didn't work" means ... ?

Look at log file for Apache Tomcat connector etc/tomcat6/logs/mod_jk.log , Apache and Apache Tomcat

Try to navigate http://localhost/jsp-examples or any other mounted URL. What do you see?
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
their is nothing in the log file it is blank.

When I try any of the http://localhost/tomcat-links it gives the same thing page not found or OOPs this link appears to be broken...

Maybe their is something more I have to do with with some configuration file or something ... duno has any body got it working in apache2 and tomcat6 yet.

Did you do anything else that I haven't done???
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:their is nothing in the log file it is blank.

When I try any of the http://localhost/tomcat-links it gives the same thing page not found or OOPs this link appears to be broken...

Maybe their is something more I have to do with with some configuration file or something ... duno has any body got it working in apache2 and tomcat6 yet.



Obviously it tells that Apache Tomcat Connector hasn't been loaded. It seem that mistake is here.


I put this file in the etc/apache2/mods-available/
file named jspconnector.load
this is how apache knows where the workers.property file is in tomcat6.


Where have you seen configuration like this?

Instead you have to include reference to jspconnector.load into the Apache's configuration by adding the following include statement in Apache's httpd.conf file,
something like "include etc/apache2/mods-available/jspconnector.load"
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
Well , in the apache2.conf
it already has these lines



So I just made another load file and called it jspconnector.load put it in the mods-enabled directory.
So I don't see any problem with that???

As tomcat6 I restarted that it still the same error?

I know the connector is running on port 8009 since I did a port scan nmap say's that it is open.

So what the heck could it be?

apache has the connector , has the load file for the connector and work.properties file so on apaches end it should be all set up.

for tomcat what else do you have to do other then uncomment the connector in the server.xml file
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

and place the work.properties file under the conf directory of tomcat6


Do I have to change the redirectPor to 80 instead of 8443 don't even know what this 8443 is for???
Do I have to change the protocol I was using in my work.properties file I has it as ajp13 ???

Other then this I have no clue why it is not working.
Note I have no firewalls on so it is not a firewall issue...
The only thing I can think of is maybe the new connector is to new for the apache2 or tomcat6 I can try another on... ???

Other then that am I missing something or forgetting to do something???


Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
Wait I was wrong I had put the jspconnector.load in the wrong folder

I should have put it under mods-enabled put I noticed I put it under mods-available
1. Include /etc/apache2/mods-enabled/*.load
2. Include /etc/apache2/mods-enabled/*.conf

When I move it to the correct place I get this error


Which I have no clue on how to go about fixing it???

my jspconnector.load is this



I did check that mod_jk.so is where it said it would be in the jspconnector.load

If anybody has a clue on how to fix this error please let me know this is killing me
I don't have any clue what undefined symbol: ap_null_cleanup has to do with and what I have to do to fix it...

Thanks sorry for the double post

Also tomcat6 side is probably working correctly since the port 8009 is on but the problem is probably with the apache side.
From the above stuff. This would explain why the connector is running but apache2 is not aware of it....
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Good, you are have some progress. Most likely you have wrong version of mod_jk.so. Where did you get and what Apache version you are running?

Sam Doder wrote:Also tomcat6 side is probably working correctly since the port 8009 is on but the problem is probably with the apache side.
From the above stuff. This would explain why the connector is running but apache2 is not aware of it....


Actually, Apache Tomcat connector is not running, because it seats on Apache side, you only opened port 8009 for connection on Tomcat side.
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204


well as for the version of apache2 I cann't find how to display that but the above was in my apache2.conf file so I am assuming version 2.2

For the connector I went to this page is this not right page (I will redownload a reinstall the connector if somebody tells me which one I should use I am on ubunutu latest version)
jsp tomcat apache connectors

The tomcat version is 6 or from what I know their is only tomcat6 as the most recent version.

Thanks for any help
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:For the connector I went to this page is this not right page (I will redownload a reinstall the connector if somebody tells me which one I should use I am on ubunutu latest version)
jsp tomcat apache connectors


Which file exactly do you use know?
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
to tell you the truth I don't really remember. If you could provide a link to the correct one or list the name of the correct one.
I can retry with thar one.

I think I used 2.2 but maybe I used 1.3 duno.

An exact link would be nice just so we are on the same page.

Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
I think this one should work http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/i586/mod_jk-1.2.28-httpd-2.2.X.so
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
Well , I used that connector and now I am getting this error when I restart the apache2 server



My jspconnector.load file looks like this



Judging by the error saying it is at line 3

but what is wrong with this line the path is correct .

Note I used jspconnector_module because everything in the folder used the syntax the filename_module if it is not that then what do I use
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
It should be

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so



Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
we now I get this


I have check and the file is where it says it is.
So I don't know what could be wrong with this


Is the JkWorkersFile not the right word to use .... am I suppose to have a / before the etc ?


Also how did you know it was suppose to be jk_module is it always the name after the underscore followed by an _module
When using the lLoadModule command
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:
.. I suppose to have a / before the etc ?


Yes.

Sam Doder wrote:
Also how did you know it was suppose to be jk_module is it always the name after the underscore followed by an _module
When using the lLoadModule command


The documentation is available at http://tomcat.apache.org/connectors-doc/
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
sorry for the double post but I
tried putting / before the etc and it seem to work I get this when I restart apache2



I don't know what the 127.0.1.1 is coming from but apache2 is running and tomcat6 is running now again
But it still doesn't work work when I do http://localhost/examples

It gives me
error 404


No more Opp's so the problem now is that the JkMount is not correct path for the examples...

That is the only thing I can think of???

I check the tomcat6 logs for the jk_module.log and it now has stuff in it like

Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:


I have never seen it before, but looks like you could easily google the solution for this error.

Sam Doder wrote:
But it still doesn't work work when I do http://localhost/examples


How about accessing by IP address?

Sam Doder wrote:
I check the tomcat6 logs for the jk_module.log and it now has stuff in it like


It works, but you could check the documentation and remove outdated and unused properties
Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
Well I don't know what lines are old and not needed or what a new version that won't give me warnings would be like.

Here is my work.prop ....



apparently I have tried both 127.0.1.1 and 127.0.0.1 and localhost each give the same result doesn'y work need :8080 then it will work?

127.0.1.1 and 127.0.0.1 <---these must be the same

I do have 2 errors in the log file what does this mean and how can I get rid of this error.



I will try giving the full path to the java-examples directory maybe I have that path wrong
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sam Doder wrote:Well I don't know what lines are old and not needed or what a new version that won't give me warnings would be like


If you don't know, check with documentation.

For initial set up these properties would work. I'm not sure about your goals, so you may add something else.

Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
Ok , I will keep working at this one. Maybe I need to specify the complete path from / all the way to the folder examples
Maybe that is the problem

Anyway
I am also wondering if their is a way to get apache2 to run asp , and asp.net files.
Would be nice to have this feature as well. Since I got apache running php , soon to be jsp , hopefully also asp , asp.net

Also wondering if I didn't have tomcat installed is their away to run jsp pages on apache and not going thru tomcat to do it.
Like with php all I had to do is install the php module and I could code php pages directly in apache. Wonder if it is possible with jsp (not going thru tomcat first)


Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tomcat6 and apache
 
Similar Threads
Apache Not able to get html files & GIF files placed in the Tomcat
why we need connector for Apache and Tomcat
getLocalPort()
port redirection isse
how to remove the port number in URL