tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Re: Servlet Execution with Virtual Hosts and Invoker Problems
Date Thu, 24 Apr 2003 13:30:14 GMT
I'm the most experience person at this, I'm sure others on this list 
might see things that aren't obvious to me.

Question: Why are you so concerned about manipulating the invoker 
itself? In /var/tomcat4/conf/web.xml, tomcat sets up an invoker servlet 
for all webapplications, why do you need manipulate this? In fact, I 
believe all calls pass transparently to this default invoker in tomcat.

Virtual hosting in apache is pretty clear. We use Virtual hosting to 
setup https for our site. We currently just let Tomcat handle all our 
requests to /VDC/* But we could replace this easily with "JKMount 
/VDC/*.jsp ajp13" and "JKMount /VDC/servlets/* ajp13" too. We do this 
because, in reality, servlets can be mapped to any URI under /VDC/*.

in httpd.conf we have:

<IfDefine HAVE_JK>
    LoadModule jk_module modules/mod_jk.so
    Include /etc/httpd/conf/mod_jk.conf
</IfDefine>

<VirtualHost xxx.xxx.xxx.xxx>
    ServerName your.virtual.host.here

  <IfModule mod_jk.c>

     JKMount /VDC/* ajp13

     Alias /VDC/ "/var/tomcat4/webapps/VDC/"

     <Location WEB-INF>
       AllowOverride None
       deny from all
     </Location>
   </IfModule>

</VirtualHost>

NameVirtualHost xxx.xxx.xxx.xxx:443

<VirtualHost xxx.xxx.xxx.xxx:443>
    ServerName your.virtual.host.here

  <IfModule mod_jk.c>

     JKMount /VDC/* ajp13

     Alias /VDC/ "/var/tomcat4/webapps/VDC/"

     <Location WEB-INF>
       AllowOverride None
       deny from all
     </Location>
   </IfModule>

</VirtualHost>

---

in my current server.xml, all I have is (Minus comments and logging).

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN" debug="0">

   <Service name="Tomcat-Standalone">

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
    port="8009" minProcessors="5" maxProcessors="75"
    enableLookups="false" redirectPort="443" acceptCount="10" debug="0"
    connectionTimeout="0" useURIValidationHack="false"
    protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

    <Engine name="Standalone" defaultHost="localhost" debug="0">

       <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true">

          <Context debug="0" reloadable="true"
          docBase="VDC" path="/VDC"/>

       </Host>

    </Engine>

  </Service>

</Server>

---

Our workers.properties just looks like this:

workers.tomcat_home=/var/tomcat4
ps=/
worker.list=ajp13

worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp13

---

The one other thing I never seen doc is that we add the apache user to 
the tomcat4 group in Linux and set the permissions on the 
/var/tomcat4/webapps directory to a+rx.

The only differences between this and what your trying, is that your 
docBase is outside the /var/tomcat4/webapps directory and your mapping 
your context to be the ROOT in that virtual host.

          <Context debug="0" reloadable="true"
          docBase="XXX" path=""/>

-Mark

Musomi Motilewa wrote:
> Alright... I'm still getting the 404 errors. Are there any sites that do 
> a step-by-step setup of a tomcat-apache combination using an invoker and 
> virtual hosts?
> 
> Mark R. Diggory wrote:
> 
>>
>>
>> Musomi Motilewa wrote:
>>
>>> See comments below for your questions. Hope this clarifies things. 
>>> Sorry about the confusion.
>>>
>>> -Musomi
>>>
>>> Mark R. Diggory wrote:
>>>
>>>> Hey, I'm just "Joe User" trying to get by same as you. ;-)
>>>>
>>>> Musomi Motilewa wrote:
>>>>
>>>>> Hi-
>>>>>
>>>>> Let me clarify my initial email below. My main problem is that the 
>>>>> servlets are not being executed when I load them using 
>>>>> http://ymusic.homedomain.com/servlet/servletName. I don't mind 
>>>>> having the /servlet directory listed when it is accessed using 
>>>>> http://ymusic.homedomain.com/servlet/ or the code of the servlet 
>>>>> displayed when its accessed using 
>>>>> http://ymusic.homedomain.com/servlet/servletName.class.
>>>>>
>>>>> At this point any URL that contains /servlet/* is processed by 
>>>>> tomcat, which is what I want it to do.
>>>>
>>>>
>>>>
>>>>
>>>> This is unclear, it sounds like your saying you *can* execute the 
>>>> servlet using /servlet/HelloWorld?
>>>
>>>
>>>
>>>
>>>
>>> None of the servlets are being executed.
>>> Tomcat catches all URLs that contain 
>>> http://ymusic.homedomain.com/servlet/
>>> http://ymusic.homedomain.com/servlet/ - lists the contents of the 
>>> servlet directory, which is the WEB-INF/classes directory
>>> http://ymusic.homedomain.com/servlet/servletName*.class* - which is a 
>>> link to the class file, returns the code for the class
>>> http://ymusic.homedomain.com/servlet/servletName - which is a link to 
>>> the servlet returns a 404 error
>>
>>
>>
>> Here's a thought, consider looking at the default server.xml provided 
>> by tomcat, you will see a layout that looks like this:
>>
>> <Engine name="Standalone" defaultHost="localhost" debug="0">
>>     <!-- Define the default virtual host -->
>>     *<Host name="localhost" debug="0" appBase="webapps" 
>> unpackWARs="true" autoDeploy="true">*
>>         <!-- Tomcat Root Context -->
>>               *<Context path="" docBase="ROOT" debug="0"/>*
>>         <!-- Tomcat Examples Context -->
>>         <Context path="/examples" docBase="examples" debug="0" 
>> reloadable="true" crossContext="true">
>>             ...
>>         </Context>
>>     </Host>
>> </Engine>
>>
>> Notice that while the path for the ROOT Context is "", that the 
>> docBase is in the directory ROOT (ie /var/tomcat4/webapps/ROOT). It 
>> may be the case that the <host docBase="..."> shouldn't be the 
>> directory of your webapplication itself. Maybe your config should have 
>> its host in "/home/ymusic" and the contexts docbase in "public_html", 
>> while keeping the the contexts path "", like this:
>>
>> <!-- Define an Apache-Connector Service -->
>> <Service name="Tomcat-Apache">
>>     <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
>>         port="8013" minProcessors="5" maxProcessors="75"
>>         acceptCount="10" debug="0"/>
>>     <Engine name="Apache" debug="0">
>>         <Logger            
>> className="org.apache.catalina.logger.FileLogger"
>>         prefix="apache_log." suffix=".txt"
>>         timestamp="true"/>
>>         <Realm
>>         className="org.apache.catalina.realm.MemoryRealm" />
>>         <Host name="ymusic.homedomain.com" debug="0"
>>         appBase="/home/ymusic" unpackWARs="true">
>>                     <Context path="" docBase="public_html" debug="0"
>>             reloadable="true"
>>             crossContext="true" />
>>         </Host>
>>     </Engine>
>> </Service>
>>
>>>
>>>>
>>>>> However I noticed the directory listing of the /servlet directory 
>>>>> via Tomcat is coming up as "Directory listing for /" instead of 
>>>>> "Directory listing for /servlet". I think this is one idication of 
>>>>> why I'm getting 404 errors when I try to load the servlets.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Again now it sounds like your saying the opposite, it sounds like 
>>>> your saying you *can't* execute the servlet using 
>>>> /servlet/HelloWorld and get a 404? 
>>>
>>>
>>>
>>>
>>>
>>> The servlets aren't being executed, but the servlet directory is 
>>> being listed. Youc an see all the *.class* files stored in the 
>>> WEB-INF/classes directory.
>>> Tomcat renders this list. The thing is the listing is labeled as the 
>>> directory listing for "/" not "/servlet". As if Tomcat sees the 
>>> /servlet directory as the root directory.
>>> On the other hand the 404 errors when I try to access the servlets 
>>> have "/servlet/servletName", which seems to indicate its looking for 
>>> the servlets in the /servlet path.
>>>
>>>>
>>>>> I've tried removing the following context from the server.xml file:
>>>>>
>>>> you really shouldn't be mounting the /servlet directory as a 
>>>> context, its not the way the configuration works:
>>>>
>>>> <Context> is for a Webapplication mount point with the following 
>>>> directory/war structure.
>>>>
>>>> path/WEB-INF/web.xml
>>>> path/WEB-INF/classes
>>>> path/WEB-INF/lib
>>>>
>>>> the context makes the webapplication available in tomcat. Context is 
>>>> not a directive to expose directories in Tomcat. I doubt its very 
>>>> logical to mount a directory in an webapplication as another 
>>>> webapplication.
>>>
>>>
>>>
>>>
>>>
>>> That is exactly what I want. I want to be able to call class files 
>>> stored in the WEB-INF/classes folder from jsp pages and URLS in the 
>>> site. This is the directory structure I have.
>>>
>>>   /home/ymusic/public_html
>>>   /home/ymusic/public_html/WEB-INF/classes
>>>   /home/ymusic/public_html/WEB-INF/lib
>>>   /home/ymusic/public_html/WEB-INF/web.xml
>>>
>>
>> Get your public_html webapplication mounted properly and it will be 
>> taking care of this accessability for you. Thats the job of the 
>> webapplication.
>>
>>> Tomcat is delivering the 404 error pages.
>>>
>>
>> In which case I think its your server.xml thats breaking things.
>>
>> -Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


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


Mime
View raw message