Adding Recaptcha and Accessing Tomcat Through Apache Http Server

Recaptcha

  1. Register a recaptcha for localhost
  2. Add this dependency to your project's pom file
  3. Add this Recaptcha resource class and this helper class to your project
  4. Update the class files with your site and secret keys produced during the registration of your recaptcha
  5. Depending on your project name try running something like http://localhost:8080/gettingstartedwithrest/recaptcha

Apache Http Server

  1. Find your apache2/httpd.conf file, (e.g. /etc/apache2)
  2. Add/replace/extend the workers.properties file in your apache2 directory. It is important that any file you add as the same ownership and permissions as other files in the same directory.
  3. In your Tomcat server.xml file make sure the followng line is uncommented and set to port 9009 matching what is in the workers.properties file
  4. <Connector port="9009" protocol="AJP/1.3" redirectPort="8443"/>

  5. Add the following to the end of your httpd.conf file, making sure the file paths exists:

    <IfModule jk_module>
    JkShmFile /var/log/apache2/jk-runtime-status.log
    JKWorkersFile /etc/apache2/workers.properties
    JKLogFile /var/log/apache2/mod_jk.log
    JKLogLevel info
    JKMountCopy All
    JKMount /social/login tomcatWorker
    JKMount /social/initial tomcatWorker
    </IfModule>

  6. Look where the modules are loaded near the beginning of the httpd.con file and make sure the jk_module is loaded, e.g. LoadModule jk_module libexec/apache2/mod_jk.so (e.g. /usr/libexec/apache2). If not mod_jk.so files exists go here and get it for your version of apache, or ask me.
  7. Start up Tomcat from Eclipse and then turn web sharing on from your system preferences.
  8. Try to access your Tomcat aps by entering http://localhost/social/initial, e.g. leaving off the 8080 port reference to Tomcat