14 Replies Latest reply on Aug 22, 2003 5:53 PM by Jon Barnett

    Step by Step

    Steve Ahlstrom Newbie

      Are there any step by step instructions available to get the JBoss-Tomcat-Apache trio working together?

      I've got the JBoss-Tomcat part going but can't figure out the Apache part. I've got mod_jk, put in the LoadModule in the httpd.conf file, but don't know where to go from there.

      Any help would be appreciated.

        • 1. Re: Step by Step
          Jon Barnett Master

          mod_jk is a bit more complicated to configure since the configuration is split - it also takes longer to explain. mod_jk2 is the more recent incarnation. If you can switch to that (best with Apache 2.0), you can find a technote at http://www.amitysolutions.com.au/documents/JK2-technote.pdf. You will need Acrobat 5.0 to read the file.

          For JK, this is a fairly simple tutorial. It doesn't cover the Apache <-> firewall <-> Tomcat situation. http://www.serverwatch.com/tutorials/article.php/10825_2203891_1. Don't configure JK to operate with JNI - that is; don't make Apache start-up Tomcat.

          Hope that helps.

          • 2. Re: Step by Step
            Steve Ahlstrom Newbie

            Thanks again!

            I had already found http://www.serverwatch.com/tutorials/article.php/10825_2203891_1 and was trying to figure things out.

            I'll take a look at your technote and will probably try to implement that.

            This stuff can be frustrating for me because I just want to develop software but feel I have to become an admin! That's what I get from wanting to move away from commerical app servers (with much better management front ends) to open source.

            General question (and I'll go do some research also). What is the advantage/disadvantage of Apache 2.0? I would think that if it's the latest and greatest it would be what is installed by default by Red Hat 9, yet it isn't. What's the deal?

            • 3. Re: Step by Step
              Jon Barnett Master

              RedHat 9.0 has a new threading model so probably you will benefit from thread scalability in Apache 2.0.

              The Apache 2.0 blurb:
              Better non-UNIX platform support
              Multi-language error responses
              UNIX POSIX-threading support for improved scalability in most cases
              Better regular expression support using the Perl 5 syntax
              Native Windows NT Unicode support for filename encoding
              Simplified configuration

              Some minor improvements are things like Ralf Engelschall's mod_ssl finally becoming part of the core distribution.

              RedHat will sometimes lag until it feels comfortable with stability. I've heard there are some problems with the mod_ssl compile in RedHat 9 - due to some issue with OpenSSL or the manner in which RedHat have installed it. Apache 2.0 builds and runs fine on my RedHat 7.2 distributions.

              Note that unless there is a specific reason for requiring Apache for your development you can run JBoss/Tomcat by itself as a functional web-server/application-server combination.

              Usually you introduce Apache for performance reasons where you split out your static content into Apache. At least in the early stages, you can avoid the network/integration issues of sticking the infrastructure together by not throwing Apache into the mix.

              • 4. Re: Step by Step
                Steve Ahlstrom Newbie

                Good stuff to think about -- thank you.

                And before someone corrects me, I was wrong .... Apache v2.x is the default on Red Hat 9.

                • 5. Re: Step by Step
                  Steve Ahlstrom Newbie

                  I'm trying to follow your technote but have (again) run into problems.

                  The source for the connector I'm using is jakarta-tomcat-connectors-jk2-2.0.2-src

                  The code fragment you list for jk/native2/configure is not in the version from the source I have -- there's something very close, but not identical.

                  Also the lines ....

                  ./configure --with-tomcat40=/usr/local/tomcat -4.1 \
                  --with-tomcat41=/usr/local/tomcat-4.1 \
                  --with-apache2=/usr/local/apache2 --with-apxs2=/usr/local/apache2/bin/apxs

                  I don't have an apxs on my system. The closest I have is /var/www/manual/programs/apxs.html

                  • 6. Re: Step by Step
                    Jon Barnett Master

                    I've had a look at the clean room unpack of 2.0.2. The problem is there in the .tar.gz and .zip distributions. With vi, I find it on line 8146 of jk/native2/configure. The code in question occurs in the --with-apache2 block of test code.

                    If it already does the test for directory instead of a file (-d and not -f) then you can leave it alone.

                    apxs is the required binary that comes with the Apache 2.0 distribution. It is used to load your extension libraries - like mod_jk2.so. It should be in the bin directory of your Apache 2.0 installation - the same directory as apachectl, httpd and checkgid. Hopefully RedHat haven't given you a half-baked RPM. You will need to change the command line for your appropriate location. In my example, this is /usr/local/apache2 for the Apache installation.

                    Hope that helps you find the necessary parts. If your RedHat distribution really doesn't have the binaries for Apache, you may need to build your own.

                    • 7. Re: Step by Step
                      Steve Ahlstrom Newbie

                      I triple checked .... apxs (and checkgrid) are not on my system (a slightly customized "server" install of Red Hat 9). apachectl and httpd are in /usr/sbin, there is no "apache2" anywhere either.

                      rpm -q httpd reveals httpd-2.0.40-21.3

                      • 8. Re: Step by Step
                        Steve Ahlstrom Newbie


                        I uninstalled the Red Hat httpd RPM, and built the current (2.0.47) version. I used all of the default paths, everything built and installed fine.

                        I then used your technote and everything worked as expected.

                        Just ONE MORE question ....

                        I want my app (idea.war) to run when the URL is just http://www.mydomain.com -- what do I set the context to in jboss-web.xml and the [uri:] in workers2.properties? I've tried the combinations but haven't gotten it to work yet with that url.


                        • 9. Re: Step by Step
                          Jon Barnett Master

                          If you want the redirection to only work for that address, you would change your URI to the following:

                          info=Map the whole domain

                          This does require that Apache can resolve the domain and realise that it intercepts requests to that address - sometimes it is easier to test that at least Apache accepts requests by turning off JK2 and seeing that Apache responds normally to http://www.mydomain.com/. Switch JK2 on again when you are satisfied it works.

                          If your jboss-web.xml is still set to the "/" context it will
                          operate as expected - otherwise when Apache successfully redirects requests to Tomcat, Tomcat will show the standard context not defined or similar type message.

                          If Apache cannot locate the Tomcat AJP13 port, it will provide a message to the effect that the container is down for maintenance or unavailable.

                          • 10. Re: Step by Step
                            Steve Ahlstrom Newbie

                            Worked great -- thanks again!

                            • 11. Re: Step by Step
                              Steve Ahlstrom Newbie

                              Ok, I'm stuck again ....

                              JBoss/Tomcat/Apache ... since www.mydomain.com is being redirected from Apache to Tomcat, how do I access graphics in Apache's docroot?

                              • 12. Re: Step by Step
                                Jon Barnett Master

                                This is where mapping becomes complex. A lot of people don't install their web applications in the root context for this reason.

                                You would need to apply more selective mapping and perhaps look at moving files around or renaming them to aid in blanket mapping.

                                For example, you may have all your dynamic mapping via JSPs and maybe all JPGs in an /image directory from the servlet container. So your URIs would be:

                                info=Map JSPs in the root context

                                info=Map JPGs in the /image context

                                With these filters, anything that matches gets forwarded to JBoss/Tomcat. Apache will handle anything that doesn't match.

                                • 13. Re: Step by Step
                                  Steve Ahlstrom Newbie

                                  Thanks again, I'll give that a try.

                                  I just may have to go back to what I was doing with JRun (and was trying to avoid here) ... not map my app to the root context and have a index.html page that just did a meta redirect to www.mydomain.com/idea

                                  • 14. Re: Step by Step
                                    Jon Barnett Master

                                    Now, the only thing you will need to do is deal with someone entering http:// www.mydomain.com/. You will need to compile into your Apache distribution the rewrite module (via --with-rewrite=shared) - a nice feature in Apache 2.0 with proper pattern matching. You will need to add the following to httpd.conf:

                                    LoadModule rewrite_module modules/mod_rewrite.so
                                    <VirtualHost www.mydomain.com:80>
                                    ServerName www.mydomain.com
                                    # Append index.jsp to URI if we find URI '/'
                                    RewriteRule ^/$ /index.jsp [R]

                                    Note that for your redirect if you remap the application to /idea, rather than having a HTML-based redirect you can do the following:

                                    LoadModule rewrite_module modules/mod_rewrite.so
                                    <VirtualHost www.mydomain.com:80>
                                    ServerName www.mydomain.com
                                    # Append index.jsp to URI if we find URI '/'
                                    RewriteRule ^/$ /idea [R]

                                    Hope that helps.