You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sriganesh Ananth <sr...@gmail.com> on 2009/04/23 21:57:45 UTC

Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Chuck, Thank you for your reply.

I didn't copy 4.1 server.xml but instead build it fresh on 5.5
provided server.xml.

Following is the server.xml (removed comments and commented lines)
-------------------------------------------------------------------------------------------------------
<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
/>
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <Listener className="org.apache.jk.config.ApacheConfig"
modJk="/usr/lib64/httpd/modules/mod_jk.so"
workersConfig="/etc/httpd/conf/workers.properties" />

  <GlobalNamingResources>

    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>

  <Service name="Catalina">


    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Catalina" defaultHost="localhost">


      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>


<!--Added by Sriganesh on 04/16-->
<!-- Define the virtual host -->
      <Host name="192.168.1.23" debug="1" appBase="/var/www/testapp"
unpackWARs="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="oss_access_log." suffix=".txt"
                 pattern="common"/>

        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="oss.com_log." suffix=".txt"
                timestamp="true"/>

        <Context path="" docBase="" debug="0"
                 reloadable="false" crossContext="true">

        <Logger className="org.apache.catalina.logger.FileLogger"
                     prefix="oss_ROOT_log." suffix=".txt"
                  timestamp="true"/>
        </Context>

      </Host>

<!--End editing-->


      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

      </Host>

    </Engine>

  </Service>

</Server>


Following is the context.xml content:
-------------------------------------------------------
<Context>
    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <!-- Uncomment this to disable session persistence across Tomcat
restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

Thank you again for your help.

Regards
Sriganesh


On Thu, Apr 23, 2009 at 12:35 PM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
>> From: Sriganesh Ananth [mailto:sriganesh.ananth4u@gmail.com]
>> Subject: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet
>> file in file system and reporting 404 error rather mapping in web.xml
>>
>> The issue is Tomcat 5.5.x looks for a servlet file under server's
>> physical file system and reporting HTTP 404 error rather than going to
>> the servlet mapping in web.xml.
>
> Post your server.xml file and the file containing the <Context> element for your webapp.  If you made the mistake of blindly copying your 4.1 server.xml file to 5.5, throw away what you did and start over.  There are numerous syntactic and semantic changes in 5.5 that are best handled by modifying the default 5.5 server.xml file to suit your requirements rather than trying to modify a 4.1 server.xml file to work with 5.5.
>
> I suspect you have an invalid <Host> and <Context> combination, but only if you post that can we tell for sure.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 4/24/2009 3:27 AM, André Warnier wrote:
> Sriganesh Ananth wrote:
> What also still smells fishy is the line
>> Alias /test /var/www/testapp/
> 
> Why is it there ? What does it achieve, that the following 2 lines do not ?
>> JkMount /*.do ajp13
>> JkMount /*.jsp ajp13

Static content?

> I have a much longer and detailed explanation of my above comments ready
> for you if you are interested, but if your purpose was simply to get
> this running on some test system, then it may not be worth it.
> But at least read this
> http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
> (the section entitled "Configuring Apache to serve static web
> application files")

My preferred Apache httpd configuration is something like this:

  Alias /contextName /path/to/webapp/root

  JkStripSession On

  JkMount /contextName/*.do myWorker
  JkMount /contextName/*.jsp myWorker

  <Location "/diagnosis">
    Order Allow,Deny
    Allow from all
    SetEnvIf X-Moz "prefetch" x_moz_prefetch
    Deny from env=x_moz_prefetch

    ErrorDocument 403 /contextName/forbidden.html
    ErrorDocument 404 /contextName/not_found.html
    ErrorDocument 500 /contextName/down.html

    # This one means 'servlet unavailable'
    ErrorDocument 503 /contextName/down.html
  </Location>

  # Directories above this one should already be protected
  # elsewhere. MAKE SURE THEY ARE.
  <Directory "/path/to/webapp/root">
    Order allow,deny
    Allow from all

    Options -Indexes

    DirectoryIndex index.html
  </Directory>
  <Directory "/path/to/webapp/root/WEB-INF">
    Order deny,allow
    Deny from all
  </Directory>
  <Directory "/path/to/webapp/root/META-INF">
    Order deny,allow
    Deny from all
  </Directory>

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknxyd4ACgkQ9CaO5/Lv0PBorwCeIY545r0PJNLylxOSP9Ydi8og
zA0AoL3+bbwxxUw/gd2SyG83/tJtJH6W
=za//
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Posted by André Warnier <aw...@ice-sa.com>.
Sriganesh Ananth wrote:
> Hi Andre,
> 
> I got Forbidden - You don't have permission to access
> /test/WEB-INF/web.xml on this server.
> 
> Under httpd.conf, just before VirtualHost I have following to deny all
> from accessing WEB-INF folder.
> 
> Httpd.conf configuration:
> 
> # Globally deny access to the WEB-INF directory
> <LocationMatch '.*WEB-INF.*'>
>        deny from all
> </LocationMatch>
> <VirtualHost …>
> DocumentRoot /var/www/testapp
> Alias /test /var/www/testapp/
> JkMount /*.do ajp13
> JkMount /*.jsp ajp13
> </VirtualHost>
> 
> Do you still smell something fishy here?
> 
Ok, that "LocationMatch" (which you did not mention before, and which 
still smells fishy if it is really outside of your <VirtualHost> 
section), makes things somewhat better, although it still smells like fish.

By the way, as written, that is a *very expensive* match, and one that 
will also match things like
/any/path/even/NOT-WEB-INF/abc.gif
/any/path/even/WEB-INFORMATION-DEPARTMENT/abc.gif
and under Windows, will not stop people getting to your WEB-INF like so 
: http://192.168.1.23/test/web-inf/web.xml

What also still smells fishy is the line
 > Alias /test /var/www/testapp/

Why is it there ? What does it achieve, that the following 2 lines do not ?
 > JkMount /*.do ajp13
 > JkMount /*.jsp ajp13

As a matter of fact, in the case of your configuration above, what does 
the Apache httpd front-end achieve, that Tomcat alone could not ?
(I am not saying that you do not have good reasons to have an Apache 
httpd in front. Just that it is not very evident from the above why you 
need it. And if you don't need it, you would gain simplicity and 
efficiency by taking it out of the equation).

I have a much longer and detailed explanation of my above comments ready 
for you if you are interested, but if your purpose was simply to get 
this running on some test system, then it may not be worth it.
But at least read this
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
(the section entitled "Configuring Apache to serve static web 
application files")



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Posted by Sriganesh Ananth <sr...@gmail.com>.
Hi Andre,

I got Forbidden - You don't have permission to access
/test/WEB-INF/web.xml on this server.

Under httpd.conf, just before VirtualHost I have following to deny all
from accessing WEB-INF folder.

Httpd.conf configuration:

# Globally deny access to the WEB-INF directory
<LocationMatch '.*WEB-INF.*'>
       deny from all
</LocationMatch>
<VirtualHost …>
DocumentRoot /var/www/testapp
Alias /test /var/www/testapp/
JkMount /*.do ajp13
JkMount /*.jsp ajp13
</VirtualHost>

Do you still smell something fishy here?

Regards
Sriganesh

On Thu, Apr 23, 2009 at 2:41 PM, André Warnier <aw...@ice-sa.com> wrote:
> Sriganesh Ananth wrote:
>>
>> Chuck, you rock!!!
>
> That part, I tend to agree.
>
>>
>> I changed the appBase to "/var/www" for Host, added "testapp" in the
>> Context docBase and restarted the tomcat and it worked!!!
>>
> But this part, and what follows :
>
> Httpd.conf configuration:
> <VirtualHost …>
> DocumentRoot /var/www/testapp
> Alias /test /var/www/testapp/
> JkMount /*.do ajp13
> JkMount /*.jsp ajp13
> </VirtualHost>
>
> I definitely find bizarre.
>
> Can you try the following URL in your browser :
>
> http://192.168.1.23/test/WEB-INF/web.xml
>
> and let us know what you get ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Posted by André Warnier <aw...@ice-sa.com>.
Sriganesh Ananth wrote:
> Chuck, you rock!!!

That part, I tend to agree.

> 
> I changed the appBase to "/var/www" for Host, added "testapp" in the
> Context docBase and restarted the tomcat and it worked!!!
> 
But this part, and what follows :

Httpd.conf configuration:
<VirtualHost …>
DocumentRoot /var/www/testapp
Alias /test /var/www/testapp/
JkMount /*.do ajp13
JkMount /*.jsp ajp13
</VirtualHost>

I definitely find bizarre.

Can you try the following URL in your browser :

http://192.168.1.23/test/WEB-INF/web.xml

and let us know what you get ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Posted by Sriganesh Ananth <sr...@gmail.com>.
Chuck, you rock!!!

I changed the appBase to "/var/www" for Host, added "testapp" in the
Context docBase and restarted the tomcat and it worked!!!

I will work on migrating the Context elements to the META-INF folder
as suggested by you.

Again, thank you very much for your help on this and you have have a
wonderful day.

Regards
Sriganesh


On Thu, Apr 23, 2009 at 1:06 PM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
>> From: Sriganesh Ananth [mailto:sriganesh.ananth4u@gmail.com]
>> Subject: Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching
>> servlet file in file system and reporting 404 error rather mapping in
>> web.xml
>
>>       <Host name="192.168.1.23" debug="1" appBase="/var/www/testapp"
>> unpackWARs="true">
>
> The above is wrong; the appBase should be "/var/www".
>
>>         <Logger className="org.apache.catalina.logger.FileLogger"
>>                  directory="logs"  prefix="oss.com_log." suffix=".txt"
>>                 timestamp="true"/>
>
> <Logger> elements are not used in 5.5; remove both of them.
>
>>         <Context path="" docBase="" debug="0"
>>                  reloadable="false" crossContext="true">
>
> The above is wrong; docBase should be "testapp"; you must never have an empty docBase.  A bug in prior levels of Tomcat occasionally caused something useful to happen when you did that, but it was an accident.
>
> Note that putting <Context> elements in server.xml is strongly discouraged; the proper location is in a webapp's META-INF/context.xml file, or in conf/Catalina/[host]/[appName].xml.  Also, if you're defining the default webapp, it should be named ROOT.  Read the Tomcat docs:
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching servlet file in file system and reporting 404 error rather mapping in web.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Sriganesh Ananth [mailto:sriganesh.ananth4u@gmail.com]
> Subject: Re: Tomcat migration 4.1.3 to 5.5.23: Tomcat5.5 searching
> servlet file in file system and reporting 404 error rather mapping in
> web.xml

>       <Host name="192.168.1.23" debug="1" appBase="/var/www/testapp"
> unpackWARs="true">

The above is wrong; the appBase should be "/var/www".

>         <Logger className="org.apache.catalina.logger.FileLogger"
>                  directory="logs"  prefix="oss.com_log." suffix=".txt"
>                 timestamp="true"/>

<Logger> elements are not used in 5.5; remove both of them.

>         <Context path="" docBase="" debug="0"
>                  reloadable="false" crossContext="true">

The above is wrong; docBase should be "testapp"; you must never have an empty docBase.  A bug in prior levels of Tomcat occasionally caused something useful to happen when you did that, but it was an accident.

Note that putting <Context> elements in server.xml is strongly discouraged; the proper location is in a webapp's META-INF/context.xml file, or in conf/Catalina/[host]/[appName].xml.  Also, if you're defining the default webapp, it should be named ROOT.  Read the Tomcat docs:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org