LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Connectivity issues between Tomcat 6.0.35 and Apache 2.2 Web Server (https://www.linuxquestions.org/questions/linux-software-2/connectivity-issues-between-tomcat-6-0-35-and-apache-2-2-web-server-923720/)

troubledhoster 01-14-2012 04:22 AM

Connectivity issues between Tomcat 6.0.35 and Apache 2.2 Web Server
 
Hi,

I am new to linux and been trying to setup and configure Different servers on my own obviously with many difficulties :)

I have been trying to configure Tomcat Server with Apache through mod_jk. Have configured the servers but seems that the connectivity is broken somewhere.

I am guessing this for two reasons
1: When i am opening the link to my site which is hosted on a vps server.
I could see the html pages but the JSP pages opens as an html or it displays the whole code. There is no error message displayed.

2:The mod_jk.log file does not have anything, its empty. Also when i checked the error_logs I cud see only a suucceful meesage for apche nothing about mod_jk

Mentioned bellow is the configuration in the httpd.conf

Workers.properties
server.xml

httpd.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /etc/httpd/conf/workers.properties
JkLogFile conf/mod_jk.log
JkLogLevel error
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13

Workers.properties
workers.tomcat_home=/opt/tomcat/apache-tomcat-6.0.35
workers.java_home=/opt/java/jdk1.6.0_26
ps=/
worker.list=tomcat,loadbalancer

worker.tomcat.port=8009
worker.tomcat.host=111.118.214.126
#worker.tomcat.host=localhost
worker.tomcat.type=ajp13
worker.tomcat.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat
worker.loadbalancer.sticky_session=1

bathory 01-14-2012 08:21 AM

Hi,

AFAIK in recent apache/mod_jk versions, the mod_jk related derectives should be inside a vhost container. E.g.
Code:

<VritualHost *:80>
ServerName localhost
JkWorkersFile /etc/httpd/conf/workers.properties
JkLogFile conf/mod_jk.log
JkLogLevel error
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
...
</VirtualHost>

Also note that you have defined 2 workers (tomcat,loadbalancer) in workers.properties,
Quote:

worker.list=tomcat,loadbalancer
but you're using a different one in apache config:
Quote:

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
So change the above to:
Code:

JkMount /*.jsp tomcat
JkMount /servlet/* tomcat

restart apache and see if it works

Regards

troubledhoster 01-14-2012 11:02 PM

Thanks for the Promt response , bathory. I did change the definition for the workers in the properties file as as you suggested but am still facing the same issue.

However, when I looked at the catalina.output i saw this which seems to be a problem,

NFO: Deploying web application directory _notes
Jan 15, 2012 1:18:18 AM org.apache.coyote.http11.Http11Protocol start
SEVERE: Error starting endpoint
java.net.BindException: Address already in use <null>:80
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)
at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:565)
at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:203)
at org.apache.catalina.connector.Connector.start(Connector.java:1122)
at org.apache.catalina.core.StandardService.start(StandardService.java:540)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.net.BindException: Address already in use

I kept changing the port in server.xml from 8080 to 8085 and finally 80 but its the same error message.

Mentioned below are the parameters from my server.xml
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

I read somewhere that Tomcat server cud only suffice to the requirement of hosting html + jsp pages but its usually slow. Is this true.. ? Are there any setbacks using Tomcat only as the web server.

In a panic mode I thot i must try this and I closed Apache server and with all the settings and changes in place started Tomcat and checked on the broswer

Where i was welcomed by a jakarta page , however when i changed the address to "www.mydomain.com/folder where i am keeping my files/index.html
it opened the html page. And alll the JSP pages were working.

Could anyone of you please suggest how can i tell Tomcat to point the domain to Index.html

In apache i have made a virtual server and then have directed it to use the the path where all my jsp + html pages are located.

Many Thanks for your help

bathory 01-15-2012 04:03 AM

Quote:

SEVERE: Error starting endpoint

<-snip->

I kept changing the port in server.xml from 8080 to 8085 and finally 80 but its the same error message.

<-snip->
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Leave it to the default 8080 and make sure tomcat is started before apache and it works standalone.

Quote:

I read somewhere that Tomcat server cud only suffice to the requirement of hosting html + jsp pages but its usually slow. Is this true.. ? Are there any setbacks using Tomcat only as the web server.
You can use tomcat as a webserver to serve plain html pages, but it's not optimized to do this. So in a production environment, it does not do well as a webserver. You can take a look at this for a comparison.


Quote:

Could anyone of you please suggest how can i tell Tomcat to point the domain to Index.html
If you are absolutely sure you want your tomcat to serve your static content, then you should place it under /<tomcat-install-dir>/webapps/ROOT

Regards

troubledhoster 01-15-2012 08:56 AM

Thanks a lot , bathory. That solved my problem .. For now I am using Tomcat as a server even in production wanted to perform some testing but wud look side by side at the issues with Apache and tomcat server integration at my end. Seems I must be missing something here or there at my end.

Would take that further again on the same thread maybe. Many Thanks for your help

Cheers!!


All times are GMT -5. The time now is 10:26 PM.