Note that there are some explanatory texts on larger screens.

plurals
  1. POMap requests from apache to tomcat using mod_jk
    text
    copied!<p>So, I'm aware that this might have been asked a lot already, but I really tried what I could and I couldn't fix this. I've been trying this for over two weeks and followed every single tutorial on the Apache Tomcat website, to no avail.</p> <p>So, what do I want? I want to deploy Java webservices to my server. I've got Apache httpd and tomcat running. So when I've got my webservice, I build and clean it and I copy the <code>.war</code> file to my tomcat <code>tomcat_home\webapps</code> folder.</p> <p>I've got the <code>mod_jk</code> module installed and loaded into Apache httpd (actually apache2), and then I've got these settings:</p> <p>Apache config (<code>/etc/apache2/apache2.conf</code>):</p> <pre><code># Tomcat LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so # jk_mod properties JkWorkersFile /var/lib/tomcat7/conf/workers.properties JkLogFile /var/log/apache2/mod_jk.log JkLogLevel error JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " # map requests to these folders to the tomcat worker JkMount /webservices/* apacheworker JkUnMount /*.html apacheworker JkUnMount /*.jpg apacheworker JkUnMount /*.gif apacheworker </code></pre> <p>This probably works, as the apache service restarts without a problem (when I hadn't created the log file yet, apache didn't start anymore).</p> <p>This is my <code>workers.properties</code> file (at <code>/var/lib/tomcat7/conf/workers.properties</code>): </p> <pre><code># the list of workers worker.list=apacheworker # define the workers properties worker.apacheworker.type=ajp13 worker.apacheworker.host=MYDOMAIN.COM worker.apacheworker.port=8009 worker.apacheworker.lbfactor=1 worker.apacheworker.connection_pool_timeout=600 worker.apacheworker.socket_keepalive=1 </code></pre> <p>If I'm right, the <code>JkMount</code> directive is a relative path in my apache folder. I tried it as an absolute path as well but that doesn't work either. </p> <p>So I don't have an actual directory at my <code>/var/www/webservices</code>, but I do have a symbolic link (with that exact path) pointing to my <code>/var/lib/tomcat7/webapps</code> directory. This way, when I copy a <code>.war</code>-file into my <code>webapps</code>-directory, it gets deflated automatically by tomcat (that works) and it should be accessible from my address "MYDOMAIN.COM/webservices/MYNEWAPP".</p> <p>However, it doesn't work. Is there anyone that can enlighten me in what I'm exactly doing wrong? Right now, when trying to open the page, I get the code just showing up - so it's not being processed at all.</p> <p>Thanks in advance!</p> <hr> <p><em><strong>EDIT</em></strong> So I tried the following: </p> <ul> <li>I already had placed <code>localhost</code> instead of my own domain in the <code>workers.properties</code></li> <li>I dropped the <code>lbfactor</code></li> </ul> <p>This is how my <code>workers.properties</code> file looks like now:</p> <pre><code># the list of workers worker.list=apacheworker # define the workers properties worker.apacheworker.type=ajp13 worker.apacheworker.host=localhost worker.apacheworker.port=8009 worker.apacheworker.connection_pool_timeout=600 worker.apacheworker.socket_keepalive=1 </code></pre> <p>Further more, I changed my <code>/etc/apache2/apache2.conf</code> as well (I don't use a separate <code>mod_jk.conf</code>), to block access to my WEB-INF directory and remove the unneccessary mappings:</p> <pre><code># Tomcat LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so # jk_mod properties JkWorkersFile /var/lib/tomcat7/conf/workers.properties JkLogFile /var/log/apache2/mod_jk.log JkLogLevel error JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " # map requests to these folders to the tomcat worker JkMount /webservices/* apacheworker &lt;Location "/Hello_World/WEB-INF"&gt; AllowOverride None deny from all &lt;/Location&gt; </code></pre> <p>All this didn't help (restarted both apache and tomcat servers as well). I still see the source from my .jsp file: </p> <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;JSP Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hello World!&lt;/h1&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Where I think I lost you: </p> <pre><code>"Notice that by default the URI for your war is the name of the war file, so that myapp.war will be accessed by calling http://mydomain.com/myapp, not http://mydomain.com/webservices/myapp. The /webservices/ mapping is relevant only if you have a webservices.war file in the tomcat's webapps directory. " </code></pre> <p>So, my webserver (<code>apache httpd</code>) serves everythings that is in my <code>/var/www/</code> directory. In that directory, I have a symlink called <code>webservices</code> that points directly to my <code>tomcat_home\webapps</code> folder. So, calling <code>ls -la</code> gives me this:</p> <pre><code>lrwxrwxrwx 1 root root 24 Nov 16 16:48 webservices -&gt; /var/lib/tomcat7/webapps </code></pre> <p>In that <code>webapps</code> folder I have my actual .war files, including Hello_World. So I don't know how I'd need to reach those files by typing in "<a href="http://mydomain.com/Hello_World" rel="nofollow">http://mydomain.com/Hello_World</a>" - that simply gives me a 404...</p> <p>Thanks for helping me out!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload