8 Replies Latest reply on Jul 8, 2002 5:24 PM by Emmanuel Potvin

    Tomcat WARP connector and Apache

    Pete Beck Newbie

      First of all, apologies for posting here, as my problem is not strictly related to JBoss, as I expect the problem actually lies with Tomcat or Apache. I find that JBoss seems to be better supported, and I am sure there are others who have experienced the same problem.

      My configuration is as follows, JBoss 2.4.4, Catalina 4.0.1 bundle, SuSe Linux 7.1, with homemade 2.4.17 kernel.
      Apache version, 1.3.14 and the new WarpConnector module.

      The problem seems to occur regardless of which JVM I use.

      I am using apache to route requests to Tomcat/JBoss via the Warp connector, and everything works great.
      The only problem is, I keep getting these exceptions:

      [ERROR,EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConnection] Exception on socket
      java.io.IOException: Premature packet header end
      at org.apache.catalina.connector.warp.WarpConnection.recv(WarpConnection.java:237)
      at org.apache.catalina.connector.warp.WarpRequestHandler.handle(WarpRequestHandler.java:112)
      at org.apache.catalina.connector.warp.WarpConnection.run(WarpConnection.java:194)
      at java.lang.Thread.run(Thread.java:484)


      The exception doesn't seem to cause any problems, but I am worried about 2 things:

      1) What effect it will have in production?
      2) The spurious log output it generates

      Has anyone has this problem and/or found a solution for it?

      My reasons for using apache are as follows:

      1) It generates access logs, which I can analyse with tools like webalizer.
      2) There is some security that mimises the risk of having to run as superuser on port 80. (On SuSe it makes use of a wwwrun user)

      If I had a solution for these two problems, I'd be happiest to ditch apache completely as it adds a
      significant overhead to my application. (200-400%)!

      Additionally, there is a problem when you redeploy your application, you must also restart apache to prevent problems

        • 1. Re: Tomcat WARP connector and Apache
          Matt Newbie

          Before I started my attempt to get JBoss -> Tomcat -> Warp -> Apache working, I had Tomcat -> Warp -> Apache working under Solaris and I got the same errors in the logs.
          Here's what I know: (I'm using Solaris 8, JDK1.3, Tomcat 4.0.1, Apache 1.3.22)

          1. When Apache starts up I got the following errors...
          [Mon Feb 18 14:58:54 2002] [warn] Loaded DSO libexec/mod_webapp.so uses plain Apache 1.3 API, this module might crash under EAPI! (please recompile it with -DEAPI)

          2. When using the version above, I get the errors you mention in the log file and I do have general process instability. (Every 3-4 weeks Apache just crashes.)

          3. Last last week, I did the suggested recompile in the error messages, there is no longer an error at startup, and I have yet to see the Premature packet header end error.... but that doesn't mean that I won't....

          I hope that helps, but now I have a Tomcat WARP Connector question for you...

          I have succeeded in getting WARP to correctly deploy .war files in $CATALINA_HOME/webapps But what I really want is for warp to be able to deploy the .war components of .ear files.

          In other words, I have not been able to get the tomcat-test.ear file that comes with the JBoss+Tomcat bundle to work while under warp. There is another forum thread where someone mentions that they use:

          WebAppDeploy jboss conn /jboss

          but that just doesn't make sense... I know the context for the tomcat-test.ear file is jboss, and I've gotten that working with just the HTTP Connector, but lets suppose for a minute I have an irrational desire to get WARP working :-) Can you tell me how yours is set up if you are in fact able to reference .ear files through WARP? Thanks, hope the info above was helpful.

          • 2. Re: Tomcat WARP connector and Apache
            Pete Beck Newbie

            As for the EAPI problem, I had already fixed this one, so sadly it isn't the cause of my problem. Although I have a suspicion that I am only getting the errors when, static content is being retrieved - particularly binary data.

            As for your question, I am happy to help with what I know. You may already know some of the stuff I mention below, but I will elaborate for others that are trying to get this working.

            Firsty, you must deploy your .ear files in $JBOSS_HOME/deploy rather than $CATALINA_HOME/webapps.
            AFAIK, $CATALINA_HOME/webapps is redundant when using JBoss.

            To get the WARP connector working, you basically need to edit two conf files: your jboss.jcml and your httpd.conf ( for apache ).
            Some people may prefer to put the httpd.conf changes into a separate conf file (e.g. warp.conf) and link them in to the main httpd.conf.

            If you already have Tomcat+Warp+Apache working, the chances are, you have already editted your httpd.conf.

            If not, you will need to add some lines like this:
            # Change this to point to the path of your module
            LoadModule webapp_module /usr/lib/apache/mod_webapp.so

            AddModule mod_webapp.c

            WebAppConnection conn warp localhost:8008

            # Replace your_application below with the name of your
            # war file, minus the .war extension
            # The forward slash at the end indicates that the
            # application will be deployed from the (URLs) root path.
            # You can change this to be whatever path you wish your
            # application to run from.
            # e.g. if you change it to /foo, then you will be
            # able to access you application as:
            # http://localhost/foo/mypage.jsp
            WebAppDeploy your_application conn /

            # This is useful if you wish to debug your installation
            WebAppInfo /webapp-info

            Now for you jboss.jcml. This is where the fun starts as this will *only* work in JBoss 2.4.4, although I haven't tried in on 3.0a. This took some figuring out as the JBoss docs were all wrong. :-)
            Find your catalina mbean and change it as below (Sorry about the tab damage).






            Now if your .ear file has deployed correctly in $JBOSS/deploy, then you should be able to access your apps from apache.

            If the above doesn't work for you, then the first thing to try, is to access your application from Tomcat's port 8080. If you can't access your application from that port either, then there is probably something wrong with your ear file, rather than your WARP configuration.

            Hope this of some help.

            Cheers,
            Pete Beck

            • 3. Re: Tomcat WARP connector and Apache
              Pete Beck Newbie

              Oops, I've just noticed that I forgot the close the
              attribute tag, in the jboss.jcml config I posted above.

              But you spotted that, right? :-)

              • 4. Re: Tomcat WARP connector and Apache
                Chris Smith Newbie

                Has anybody managed to do this AND use virtual hosts?

                I have Apache, Warp, and the JBoss2.4.4 + Tomcat 4.0.1 bundle working using the config Pete suggests, but when I try to use a virtual host, Catalina tries to find the webapp under it's webapps directory rather than using the deployed ear file from JBoss.

                My additions to httpd.conf are:

                ######### start
                NameVirtualHost *

                WebAppConnection conn warp localhost:8008

                <VirtualHost *>
                ServerName ike.home
                DocumentRoot /var/www/html/ike


                <VirtualHost *>
                ServerName pickle.home
                DocumentRoot /var/www/html/pickle
                WebAppDeploy jobsite conn /jobsite/
                WebAppInfo /webapp-info

                ################ end

                With this config and ike.home and pickle.home in another machine's hosts file (linux machines), I can happily browse to either virtual host from the other machine (for plain html files served by Apache).

                I can also access the jobsite.ear deployed in JBoss using either http://pickle.home:8080/jobsite or http://ike.home:8080/jobsite.

                But as soon as I try http://pickle.home/jobsite (or even http://ike.home/jobsite), Catalina looks for jobsite.war in it's webapps directory. The EmbeddedCatalinaServiceSX repeats an error message over and over to that effect. Here's the JBoss output from just when it deploys the ear file to when I connect via Apache:

                [11:40:24,437 INFO ContainerFactory] Deployed application: file:/home/chris/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/jobsite.ear
                [11:40:24,438 INFO J2eeDeployer] Starting module jobsite-web.war
                [11:40:24,442 INFO EmbeddedCatalinaServiceSX] deploy, ctxPath=/jobsite, warUrl=file:/home/chris/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/jobsite.ear/web1002/
                [11:40:24,648 INFO EmbeddedCatalinaServiceSX] WebappLoader[/jobsite]: Deploying class repositories to work directory /home/chris/JBoss-2.4.4_Tomcat-4.0.1/catalina/work/localhost/jobsite
                [11:40:24,665 INFO EmbeddedCatalinaServiceSX] WebappLoader[/jobsite]: Deploy JAR /WEB-INF/lib/cactus.jar to /home/chris/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/jobsite.ear/web1002/WEB-INF/lib/cactus.jar
                [11:40:24,675 INFO EmbeddedCatalinaServiceSX] WebappLoader[/jobsite]: Deploy JAR /WEB-INF/lib/junit.jar to /home/chris/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/jobsite.ear/web1002/WEB-INF/lib/junit.jar
                [11:40:24,678 INFO EmbeddedCatalinaServiceSX] WebappLoader[/jobsite]: Deploy JAR /WEB-INF/lib/struts.jar to /home/chris/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/jobsite.ear/web1002/WEB-INF/lib/struts.jar
                [11:40:24,681 INFO EmbeddedCatalinaServiceSX] StandardManager[/jobsite]: Seeding random number generator class java.security.SecureRandom
                [11:40:24,685 INFO EmbeddedCatalinaServiceSX] StandardManager[/jobsite]: Seeding of random number generator has been completed
                [11:40:24,884 ERROR Default] Error unable to create jar cache in /tmp directory : java.util.zip.ZipException: error in opening zip file
                [11:40:25,017 ERROR Default] Error unable to create jar cache in /tmp directory : java.util.zip.ZipException: error in opening zip file
                [11:40:25,032 ERROR Default] Error unable to create jar cache in /tmp directory : java.util.zip.ZipException: error in opening zip file
                [11:40:25,047 ERROR Default] Error unable to create jar cache in /tmp directory : java.util.zip.ZipException: error in opening zip file
                [11:40:25,226 INFO EmbeddedCatalinaServiceSX] ContextConfig[/jobsite]: Added certificates -> request attribute Valve
                [11:40:25,317 INFO EmbeddedCatalinaServiceSX] StandardWrapper[/jobsite:default]: Loading container servlet default
                [11:40:25,371 INFO EmbeddedCatalinaServiceSX] default: init
                [11:40:25,375 INFO EmbeddedCatalinaServiceSX] StandardWrapper[/jobsite:invoker]: Loading container servlet invoker
                [11:40:25,380 INFO EmbeddedCatalinaServiceSX] invoker: init
                [11:40:25,431 INFO EmbeddedCatalinaServiceSX] action: init
                [11:40:25,812 INFO EmbeddedCatalinaServiceSX] jsp: init
                [11:40:26,560 INFO J2eeDeployer] J2EE application: file:/home/chris/JBoss-2.4.4_Tomcat-4.0.1/jboss/deploy/jobsite.ear is deployed.
                [11:40:26,562 INFO AutoDeployer] Started
                [11:40:26,563 INFO JMXAdaptorService] Starting
                [11:40:26,566 INFO JMXAdaptorService] Started
                [11:40:26,567 INFO RMIConnectorService] Starting
                [11:40:26,585 INFO RMIConnectorService] Started
                [11:40:26,587 INFO MailService] Starting
                [11:40:27,011 INFO MailService] Mail Service 'Mail' bound to java:/Mail
                [11:40:27,012 INFO MailService] Started
                [11:40:27,013 INFO ServiceControl] Started 50 services
                [11:40:27,014 INFO Default] JBoss-2.4.4 Started in 0m:13s.786
                [11:40:31,180 INFO EmbeddedCatalinaServiceSX] jsp: init
                [11:40:31,319 INFO EmbeddedCatalinaServiceSX] jsp: init
                [11:40:39,263 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConnector] Connection from localhost.localdomain/127.0.0.1:38178 to localhost.localdomain/127.0.0.1:8008
                [11:40:39,281 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Cannot find "/home/chris/JBoss-2.4.4_Tomcat-4.0.1/catalina/webapps/jobsite" for appl. "jobsite" host "pickle.home"
                [11:40:39,282 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Error deploying web application "jobsite" under <http://pickle.home:80/jobsite/>
                [11:40:39,359 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Cannot find "/home/chris/JBoss-2.4.4_Tomcat-4.0.1/catalina/webapps/jobsite" for appl. "jobsite" host "pickle.home"
                [11:40:39,361 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Error deploying web application "jobsite" under <http://pickle.home:80/jobsite/>


                Catalina would normally look in it's webapps directory for war files, but I guess when it's bundled with JBoss, the EmbeddedCatalinaServiceSX reconfigures it so it can find the webapp once it's been deployed from the ear file. I know the bundled Catalina doesn't use it's server.xml file as I can connect to the webapp on port 8080 even if I delete it, so there's no point changing server.xml.

                The WarpConnector is a configuration parameter of EmbeddedCatalinaServiceSX, so is there another attribute I need to use to make it work with a virtual host?

                Chris

                • 5. Re: Tomcat WARP connector and Apache
                  Chris Smith Newbie

                  At last, figured it out. Looking at the source, I found that org.jboss.web.catalina.EmbeddedCatalinaServiceSXMBean has a setBindAddress method (don't you just love open source?), so I changed my jboss.jcml to this:





                  pickle.home


                  and it works. I can see the webapp on http://pickle.home/jobsite, but I can't see it on http://ike.home/jobsite, which is correct.

                  There were a few error messages when I first connected, but I but I think they're a red herring:

                  [12:21:24,513 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConnector] Connection from localhost.localdomain/127.0.0.1:38227 to localhost.localdomain/127.0.0.1:8008
                  [12:21:24,518 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConnector] Connection from localhost.localdomain/127.0.0.1:38228 to localhost.localdomain/127.0.0.1:8008
                  [12:21:24,580 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Filter mappings (0)
                  [12:21:24,589 ERROR EmbeddedCatalinaServiceSX] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Filter mappings (0)

                  The messages come out of the Warp connector and the EmbeddedCatalinaServiceSX is reporting them as errors even though they don't appear to be real errors if you look at the Warp source.

                  I hope this helps anyone else trying to use Warp, JBoss and virtual hosts. Now that I'm finished, my desk has more hair than I do :-)

                  Chris

                  • 6. Re: Tomcat WARP connector and Apache
                    Raj Saini Newbie

                    I have followed the procedure as mentioned by you. Here are the configuration of my jboss.jcml.



                    localhost



                    I have addres the BindAdress attribute later. It did not work without bind address as well.


                    My Apache config is:

                    WebAppConnection warpConnection warp localhost:8008
                    WebAppDeploy emergingtrade warpConnection /emergingtrade/
                    WebAppInfo /webapp-info
                    WebAppConnection warpConnectionTest warp localhost:8008
                    WebAppDeploy examples warpConnectionTest /examples/

                    The example application is working as it is deployed in the catalina/webapps directory.

                    Thanks for you kind help in advance.

                    • 7. Re: Tomcat WARP connector and Apache
                      Raj Saini Newbie

                      I figured it out. it is working now.

                      The bind address attribute in the jboss.jcml is required even if you are not using the virutal hosts in Apache. The name of the bind adress must match with the ServerName directive of the Apache server. I was using the ptrader name in apache and localhost in the jboss.jcml.

                      Thanks to all for the kind help.

                      • 8. Re: Tomcat WARP connector and Apache
                        Emmanuel Potvin Newbie

                        I don't understand. Here is my tomcat4-service.xml part that I have added.



                        localhost

                        I added the second part with the WarpConnector. The listener started correctly.

                        Here is my httpd.conf :

                        LoadModule webapp_module modules/mod_webapp.so
                        <IfModule mod_webapp.c>
                        WebAppConnection wco warp 127.0.0.1:8008
                        WebAppDeploy jive wco /jive
                        WebAppInfo /webapp-info


                        When I restart apache, in my jboss log, I have this:

                        2002-07-08 16:31:27,568 ERROR [org.jboss.web.localhost.Engine] [org.apache.catalina.connector.warp.WarpConfigurationHandler] Cannot find "../catalina/webapps/jive" for appl. "jive" host "127.0.0.1"

                        Why??