You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by jerrycat <si...@gmail.com> on 2008/08/25 23:47:27 UTC

Tomcat 5.5 context.xml, how to configure the Host element

Dear all, 
I understand that Tomcat 5.5 prefers that your web application comes with a
context.xml file under the META-INF folder. 

So I added a context.xml file under the META-INF folder of my web
application, please have a look below. 

context.xml 
[code] 
   
[/code] 

Ok, that is good so far, but how do I configure the Host element. 

I mean how do you link a specific Host to a specific Context? 
before, the Context element was a sub element of the Host element, now it is
completely separated. 

Host element in server.xml
[code] 
 
 
[/code] 

Please help! 
-- 
View this message in context: http://www.nabble.com/Tomcat-5.5-context.xml%2C-how-to-configure-the-Host-element-tp19152267p19152267.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by jerrycat <si...@gmail.com>.
[Tried to read the tomcat docs, but it is a bit confusing]

Right, my goal is to deploy war files that get unpacked so that I can see
the directory structure.

I am not interested in autoDeploy or deployOnStartup, unless it is
necessary.

Here is a paragraph from the docs:

"Finally, note that if you are defining contexts explicitly, you should
probably turn off automatic application deployment. Otherwise, your context
will be deployed twice each, and that may cause problems for your app."


So, I guess I am defining contexts explicitly, since I add a context.xml 
file under the META-INF
folder of each of my web apps.

This then means that autoDeploy should be set to false of my Host elements.
Also I set deployOnStartup to false since I am not in need of it.

Here is how I do:

1. Create a folder under webapps and name it test so the path is
webapps/test

2. Add this Host element:
      
          
        

3. The context.xml under the META-INF folder of the test web app:

	


4. Deploy the test web app under the webapps/test folder and name the war
file ROOT.war:
   webapps/test/ROOT.war 

5. Start Tomcat and it works:
   It works locally, when Host name is 127.0.0.2 instead of www.test.com,
have not tried yet 
   on the production server, but I assume it should.

Questions:

1. Some web apps don't need the JNDI/JDBC data source configuration,
    is it OK with an empty context element in the context.xml file:
    

2. Is all the configuration above OK (even though it works)

3. My production tomcat server (configured differently, very much the old
fashioned way with Context elements within Host elements)  after a while do
not show the websites although the tomcat server is still
running.

Could this be because of misconfiguration?
Nothing else is running on port 80 and the firewall is turned off. The OS is
windows server 2003.


Thanks for all help so far.


Markus Schönhaber-10 wrote:
> 
> jerrycat wrote:
> 
>> Thanks,
>> just a question here.
>> 
>> Set the appBase attributes for all your Host elements to different paths
>> and make sure that not one is contained in another. For example, if
>> you've got two hosts, "localhost" and "www.test.com", you could
>> configure them like that:
>>  and
>>  
>> The question:
>> If I have a subdomain, demo.test.com, should I define a new Host?
>>  The name after webapps/, which is demo.test, can it be named anyhow?
>> for example webapps/mydemotestwebapp
> 
> Yes.
> In fact, there is no law that states that the appBase has to start with 
> webapps/. You could even use absolute paths to point appBase to a 
> directory outside of your CATALINA_BASE.
> 
> Regards
>    mks
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-5.5-context.xml%2C-how-to-configure-the-Host-element-tp19152267p19169831.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by jerrycat <si...@gmail.com>.
Right,
apparently deployOnStartup must be set to true otherwise the sites don't get
uploaded.

(No idea in which case it could be set to false)

I understand that I can upload unzipped war files, but I still would like to
move over war files to my production server.

Anyway, apart from the packed and unpacked web apps, was everything else
correct,
provided that deployOnStartup is set to true.

The main issue is actually not the packed and unpacked web apps, I am
actually
trying to figure out why the sites are not showing after a while, so I am
trying to
configure everything correctly.

Thanks. 


David Smith-2 wrote:
> 
> If all you want to do is see the directory structure, why don't you just 
> unzip the .war file?  That's all a .war/.jar file essentially is -- a 
> zip archive.  Admittedly you can't just zip any folder and get a war 
> file, but you can see the contents just by unzipping it.
> 
> --David
> 
> jerrycat wrote:
>> [Tried to read the tomcat docs, but it is a bit confusing]
>>
>> Right, my goal is to deploy war files that get unpacked so that I can see
>> the directory structure.
>>
>> I am not interested in autoDeploy or deployOnStartup, unless it is
>> necessary.
>>
>> Here is a paragraph from the docs:
>>
>> "Finally, note that if you are defining contexts explicitly, you should
>> probably turn off automatic application deployment. Otherwise, your
>> context
>> will be deployed twice each, and that may cause problems for your app."
>>
>>
>> So, I guess I am defining contexts explicitly, since I add a context.xml 
>> file under the META-INF
>> folder of each of my web apps.
>>
>> This then means that autoDeploy should be set to false of my Host
>> elements.
>> Also I set deployOnStartup to false since I am not in need of it.
>>
>> Here is how I do:
>>
>> 1. Create a folder under webapps and name it test so the path is
>> webapps/test
>>
>> 2. Add this Host element:
>>       <Host name="www.test.com" deployOnStartup="false" debug="0"
>> appBase="webapps/test" unpackWARs="true" autoDeploy="false"
>> xmlValidation="false" xmlNamespaceAware="false">
>>           <Valve 
>>           
>> className="org.apache.catalina.valves.FastCommonAccessLogValve" 
>>           	prefix="access_log." 
>>           	suffix=".txt" 
>>           	pattern="common" 
>>           	directory="C:/Program Files/Apache Software Foundation/Tomcat
>> 5.5/webapps/test/logs"/>
>>       </Host>  
>>
>> 3. The context.xml under the META-INF folder of the test web app:
>> <Context>
>> 	<Resource 
>> 		name="jdbc/testDB" 
>> 		factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>> 		auth="Container" 
>> 		type="javax.sql.DataSource" 
>> 		maxActive="10" 
>> 		maxIdle="5" 
>> 		maxWait="10000" 
>> 		removeAbandoned="true"
>> 		removeAbandonedTimeout="60"
>> 		logAbandoned="true"
>> 		username="root" 
>> 		password="secret" 
>> 		driverClassName="com.mysql.jdbc.Driver" 
>> 		url="jdbc:mysql://localhost:3306/test" />
>> </Context>
>>
>> 4. Deploy the test web app under the webapps/test folder and name the war
>> file ROOT.war:
>>    webapps/test/ROOT.war 
>>
>> 5. Start Tomcat and it works:
>>    It works locally, when Host name is 127.0.0.2 instead of www.test.com,
>> have not tried yet 
>>    on the production server, but I assume it should.
>>
>> Questions:
>>
>> 1. Some web apps don't need the JNDI/JDBC data source configuration,
>>     is it OK with an empty context element in the context.xml file:
>>     <Context />
>>
>> 2. Is all the configuration above OK (even though it works)
>>
>> 3. My production tomcat server (configured differently, very much the old
>> fashioned way with Context elements within Host elements)  after a while
>> do
>> not show the websites although the tomcat server is still
>> running.
>>
>> Could this be because of misconfiguration?
>> Nothing else is running on port 80 and the firewall is turned off. The OS
>> is
>> windows server 2003.
>>
>>
>> Thanks for all help so far.
>>
>>
>> Markus Schönhaber-10 wrote:
>>   
>>> jerrycat wrote:
>>>
>>>     
>>>> Thanks,
>>>> just a question here.
>>>>
>>>> Set the appBase attributes for all your Host elements to different
>>>> paths
>>>> and make sure that not one is contained in another. For example, if
>>>> you've got two hosts, "localhost" and "www.test.com", you could
>>>> configure them like that:
>>>> <Host name="localhost" appBase="webapps/localhost" [...]
>>>> and
>>>> <Host name="www.test.com" appBase"webapps/test" [...] 
>>>>
>>>> The question:
>>>> If I have a subdomain, demo.test.com, should I define a new Host?
>>>> <Host name="demo.test.com" appBase"webapps/demo.test"
>>>>       
>>> If you want demo.test.com to be different from www.test.com, then yes.
>>> Otherwise you could define demo.test.com to be an Alias for
>>> www.test.com.
>>>
>>>     
>>>> The name after webapps/, which is demo.test, can it be named anyhow?
>>>> for example webapps/mydemotestwebapp
>>>>       
>>> Yes.
>>> In fact, there is no law that states that the appBase has to start with 
>>> webapps/. You could even use absolute paths to point appBase to a 
>>> directory outside of your CATALINA_BASE.
>>>
>>> Regards
>>>    mks
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>     
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-5.5-context.xml%2C-how-to-configure-the-Host-element-tp19152267p19170480.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by David Smith <dn...@cornell.edu>.
If all you want to do is see the directory structure, why don't you just 
unzip the .war file?  That's all a .war/.jar file essentially is -- a 
zip archive.  Admittedly you can't just zip any folder and get a war 
file, but you can see the contents just by unzipping it.

--David

jerrycat wrote:
> [Tried to read the tomcat docs, but it is a bit confusing]
>
> Right, my goal is to deploy war files that get unpacked so that I can see
> the directory structure.
>
> I am not interested in autoDeploy or deployOnStartup, unless it is
> necessary.
>
> Here is a paragraph from the docs:
>
> "Finally, note that if you are defining contexts explicitly, you should
> probably turn off automatic application deployment. Otherwise, your context
> will be deployed twice each, and that may cause problems for your app."
>
>
> So, I guess I am defining contexts explicitly, since I add a context.xml 
> file under the META-INF
> folder of each of my web apps.
>
> This then means that autoDeploy should be set to false of my Host elements.
> Also I set deployOnStartup to false since I am not in need of it.
>
> Here is how I do:
>
> 1. Create a folder under webapps and name it test so the path is
> webapps/test
>
> 2. Add this Host element:
>       <Host name="www.test.com" deployOnStartup="false" debug="0"
> appBase="webapps/test" unpackWARs="true" autoDeploy="false"
> xmlValidation="false" xmlNamespaceAware="false">
>           <Valve 
>           	className="org.apache.catalina.valves.FastCommonAccessLogValve" 
>           	prefix="access_log." 
>           	suffix=".txt" 
>           	pattern="common" 
>           	directory="C:/Program Files/Apache Software Foundation/Tomcat
> 5.5/webapps/test/logs"/>
>       </Host>  
>
> 3. The context.xml under the META-INF folder of the test web app:
> <Context>
> 	<Resource 
> 		name="jdbc/testDB" 
> 		factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> 		auth="Container" 
> 		type="javax.sql.DataSource" 
> 		maxActive="10" 
> 		maxIdle="5" 
> 		maxWait="10000" 
> 		removeAbandoned="true"
> 		removeAbandonedTimeout="60"
> 		logAbandoned="true"
> 		username="root" 
> 		password="secret" 
> 		driverClassName="com.mysql.jdbc.Driver" 
> 		url="jdbc:mysql://localhost:3306/test" />
> </Context>
>
> 4. Deploy the test web app under the webapps/test folder and name the war
> file ROOT.war:
>    webapps/test/ROOT.war 
>
> 5. Start Tomcat and it works:
>    It works locally, when Host name is 127.0.0.2 instead of www.test.com,
> have not tried yet 
>    on the production server, but I assume it should.
>
> Questions:
>
> 1. Some web apps don't need the JNDI/JDBC data source configuration,
>     is it OK with an empty context element in the context.xml file:
>     <Context />
>
> 2. Is all the configuration above OK (even though it works)
>
> 3. My production tomcat server (configured differently, very much the old
> fashioned way with Context elements within Host elements)  after a while do
> not show the websites although the tomcat server is still
> running.
>
> Could this be because of misconfiguration?
> Nothing else is running on port 80 and the firewall is turned off. The OS is
> windows server 2003.
>
>
> Thanks for all help so far.
>
>
> Markus Schönhaber-10 wrote:
>   
>> jerrycat wrote:
>>
>>     
>>> Thanks,
>>> just a question here.
>>>
>>> Set the appBase attributes for all your Host elements to different paths
>>> and make sure that not one is contained in another. For example, if
>>> you've got two hosts, "localhost" and "www.test.com", you could
>>> configure them like that:
>>> <Host name="localhost" appBase="webapps/localhost" [...]
>>> and
>>> <Host name="www.test.com" appBase"webapps/test" [...] 
>>>
>>> The question:
>>> If I have a subdomain, demo.test.com, should I define a new Host?
>>> <Host name="demo.test.com" appBase"webapps/demo.test"
>>>       
>> If you want demo.test.com to be different from www.test.com, then yes.
>> Otherwise you could define demo.test.com to be an Alias for www.test.com.
>>
>>     
>>> The name after webapps/, which is demo.test, can it be named anyhow?
>>> for example webapps/mydemotestwebapp
>>>       
>> Yes.
>> In fact, there is no law that states that the appBase has to start with 
>> webapps/. You could even use absolute paths to point appBase to a 
>> directory outside of your CATALINA_BASE.
>>
>> Regards
>>    mks
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   


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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by jerrycat <si...@gmail.com>.
[Tried to read the tomcat docs, but it is a bit confusing]

Right, my goal is to deploy war files that get unpacked so that I can see
the directory structure.

I am not interested in autoDeploy or deployOnStartup, unless it is
necessary.

Here is a paragraph from the docs:

"Finally, note that if you are defining contexts explicitly, you should
probably turn off automatic application deployment. Otherwise, your context
will be deployed twice each, and that may cause problems for your app."


So, I guess I am defining contexts explicitly, since I add a context.xml 
file under the META-INF
folder of each of my web apps.

This then means that autoDeploy should be set to false of my Host elements.
Also I set deployOnStartup to false since I am not in need of it.

Here is how I do:

1. Create a folder under webapps and name it test so the path is
webapps/test

2. Add this Host element:
      <Host name="www.test.com" deployOnStartup="false" debug="0"
appBase="webapps/test" unpackWARs="true" autoDeploy="false"
xmlValidation="false" xmlNamespaceAware="false">
          <Valve 
          	className="org.apache.catalina.valves.FastCommonAccessLogValve" 
          	prefix="access_log." 
          	suffix=".txt" 
          	pattern="common" 
          	directory="C:/Program Files/Apache Software Foundation/Tomcat
5.5/webapps/test/logs"/>
      </Host>  

3. The context.xml under the META-INF folder of the test web app:
<Context>
	<Resource 
		name="jdbc/testDB" 
		factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
		auth="Container" 
		type="javax.sql.DataSource" 
		maxActive="10" 
		maxIdle="5" 
		maxWait="10000" 
		removeAbandoned="true"
		removeAbandonedTimeout="60"
		logAbandoned="true"
		username="root" 
		password="secret" 
		driverClassName="com.mysql.jdbc.Driver" 
		url="jdbc:mysql://localhost:3306/test" />
</Context>

4. Deploy the test web app under the webapps/test folder and name the war
file ROOT.war:
   webapps/test/ROOT.war 

5. Start Tomcat and it works:
   It works locally, when Host name is 127.0.0.2 instead of www.test.com,
have not tried yet 
   on the production server, but I assume it should.

Questions:

1. Some web apps don't need the JNDI/JDBC data source configuration,
    is it OK with an empty context element in the context.xml file:
    <Context />

2. Is all the configuration above OK (even though it works)

3. My production tomcat server (configured differently, very much the old
fashioned way with Context elements within Host elements)  after a while do
not show the websites although the tomcat server is still
running.

Could this be because of misconfiguration?
Nothing else is running on port 80 and the firewall is turned off. The OS is
windows server 2003.


Thanks for all help so far.


Markus Schönhaber-10 wrote:
> 
> jerrycat wrote:
> 
>> Thanks,
>> just a question here.
>> 
>> Set the appBase attributes for all your Host elements to different paths
>> and make sure that not one is contained in another. For example, if
>> you've got two hosts, "localhost" and "www.test.com", you could
>> configure them like that:
>> <Host name="localhost" appBase="webapps/localhost" [...]
>> and
>> <Host name="www.test.com" appBase"webapps/test" [...] 
>> 
>> The question:
>> If I have a subdomain, demo.test.com, should I define a new Host?
>> <Host name="demo.test.com" appBase"webapps/demo.test"
> 
> If you want demo.test.com to be different from www.test.com, then yes.
> Otherwise you could define demo.test.com to be an Alias for www.test.com.
> 
>> The name after webapps/, which is demo.test, can it be named anyhow?
>> for example webapps/mydemotestwebapp
> 
> Yes.
> In fact, there is no law that states that the appBase has to start with 
> webapps/. You could even use absolute paths to point appBase to a 
> directory outside of your CATALINA_BASE.
> 
> Regards
>    mks
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-5.5-context.xml%2C-how-to-configure-the-Host-element-tp19152267p19169842.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by Markus Schönhaber <to...@list-post.mks-mail.de>.
jerrycat wrote:

> Thanks,
> just a question here.
> 
> Set the appBase attributes for all your Host elements to different paths
> and make sure that not one is contained in another. For example, if
> you've got two hosts, "localhost" and "www.test.com", you could
> configure them like that:
> <Host name="localhost" appBase="webapps/localhost" [...]
> and
> <Host name="www.test.com" appBase"webapps/test" [...] 
> 
> The question:
> If I have a subdomain, demo.test.com, should I define a new Host?
> <Host name="demo.test.com" appBase"webapps/demo.test"

If you want demo.test.com to be different from www.test.com, then yes.
Otherwise you could define demo.test.com to be an Alias for www.test.com.

> The name after webapps/, which is demo.test, can it be named anyhow?
> for example webapps/mydemotestwebapp

Yes.
In fact, there is no law that states that the appBase has to start with 
webapps/. You could even use absolute paths to point appBase to a 
directory outside of your CATALINA_BASE.

Regards
   mks

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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by jerrycat <si...@gmail.com>.
Thanks,
just a question here.

Set the appBase attributes for all your Host elements to different paths
and make sure that not one is contained in another. For example, if
you've got two hosts, "localhost" and "www.test.com", you could
configure them like that:
<Host name="localhost" appBase="webapps/localhost" [...]
and
<Host name="www.test.com" appBase"webapps/test" [...] 

The question:
If I have a subdomain, demo.test.com, should I define a new Host?
<Host name="demo.test.com" appBase"webapps/demo.test"

The name after webapps/, which is demo.test, can it be named anyhow?
for example webapps/mydemotestwebapp



Markus Schönhaber-10 wrote:
> 
> jerrycat wrote:
> 
>> Here is the context.xml
>> <Context path="" docBase="C://Program Files//Apache Software
>> Foundation//Tomcat 5.5//webapps//test"> 
> [...]
>> </Context>
> 
> Please read the docs:
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
> Especially the last paragraphs in the descriptions of the docBase and 
> the path attributes.
> You have not mentioned how you are going to deploy your webapp. 
> Therefore I'll simply assume you want to autodeploy a war file or an 
> exploded war file.
> In this case, remove the path and docBase attributes from the Context 
> element.
> 
>> and here is the Host element in the conf/server.xml
>> <Host name="www.test.com" deployOnStartup="true" debug="0"
>> appBase="webapps"
> 
> Set the appBase attributes for all your Host elements to different paths 
> and make sure that not one is contained in another. For example, if 
> you've got two hosts, "localhost" and "www.test.com", you could 
> configure them like that:
> <Host name="localhost" appBase="webapps/localhost" [...]
> and
> <Host name="www.test.com" appBase"webapps/test" [...]
> 
> If you want a webapp to be accessible via www.test.com, drop the 
> corresponding war file into $CATALINA_BASE/webapps/test.
> If a webapp shall be the default Context for a given Host, name it 
> "ROOT" and deploy it to the Host's appBase.
> 
>> unpackWARs="true" autoDeploy="true" xmlValidation="false"
>> xmlNamespaceAware="false"> 
> [...]
>> </Host>
> 
> Regards
>    mks
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-5.5-context.xml%2C-how-to-configure-the-Host-element-tp19152267p19161308.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by Markus Schönhaber <to...@list-post.mks-mail.de>.
jerrycat wrote:

> Here is the context.xml
> <Context path="" docBase="C://Program Files//Apache Software
> Foundation//Tomcat 5.5//webapps//test"> 
[...]
> </Context>

Please read the docs:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
Especially the last paragraphs in the descriptions of the docBase and 
the path attributes.
You have not mentioned how you are going to deploy your webapp. 
Therefore I'll simply assume you want to autodeploy a war file or an 
exploded war file.
In this case, remove the path and docBase attributes from the Context 
element.

> and here is the Host element in the conf/server.xml
> <Host name="www.test.com" deployOnStartup="true" debug="0" appBase="webapps"

Set the appBase attributes for all your Host elements to different paths 
and make sure that not one is contained in another. For example, if 
you've got two hosts, "localhost" and "www.test.com", you could 
configure them like that:
<Host name="localhost" appBase="webapps/localhost" [...]
and
<Host name="www.test.com" appBase"webapps/test" [...]

If you want a webapp to be accessible via www.test.com, drop the 
corresponding war file into $CATALINA_BASE/webapps/test.
If a webapp shall be the default Context for a given Host, name it 
"ROOT" and deploy it to the Host's appBase.

> unpackWARs="true" autoDeploy="true" xmlValidation="false"
> xmlNamespaceAware="false"> 
[...]
> </Host>

Regards
   mks

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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by jerrycat <si...@gmail.com>.
Ooops, I think the [code] tags removed the content.

Here is the context.xml
<Context path="" docBase="C://Program Files//Apache Software
Foundation//Tomcat 5.5//webapps//test"> 
	<Resource 
		name="jdbc/testDB" 
		factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" 
		auth="Container" 
		type="javax.sql.DataSource" 
		maxActive="10" 
		maxIdle="5" 
		maxWait="10000" 
		removeAbandoned="true" 
		removeAbandonedTimeout="60" 
		logAbandoned="true" 
		username="username" 
		password="password" 
		driverClassName="com.mysql.jdbc.Driver" 
		url="jdbc:mysql://localhost:3306/test" /> 
</Context> 


and here is the Host element in the conf/server.xml
<Host name="www.test.com" deployOnStartup="true" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false"> 
	<Valve 
		className="org.apache.catalina.valves.FastCommonAccessLogValve" 
		prefix="test_access_log." 
		suffix=".txt" 
		pattern="common" 
		directory="C://Program Files//Apache Software Foundation//Tomcat
5.5//webapps//test//logs"/> 
</Host>


I assume that if I modify the appBase of the Host element from webapps to
webapps/test then it would work, but if I have several
Contexts for the specific Host, how should I configure it then?


Please help by giving examples! 



Markus Schönhaber-10 wrote:
> 
> jerrycat wrote:
> 
>> I understand that Tomcat 5.5 prefers that your web application comes with
>> a
>> context.xml file under the META-INF folder. 
> 
> OK.
> 
>> So I added a context.xml file under the META-INF folder of my web
>> application, please have a look below. 
>> 
>> context.xml 
>> [code] 
>>    
>> [/code] 
> 
> Looks very ... hm ... clean.
> 
>> Ok, that is good so far, but how do I configure the Host element. 
>> 
>> I mean how do you link a specific Host to a specific Context? 
>> before, the Context element was a sub element of the Host element, now it
>> is
>> completely separated. 
> 
> Deploy your webapp to the directory you configured as appBase for the 
> corresponding host.
> 
>> Host element in server.xml
>> [code] 
>>  
>>  
>> [/code] 
> 
> Rather clean also.
> 
> Regards
>    mks
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-5.5-context.xml%2C-how-to-configure-the-Host-element-tp19152267p19158783.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Tomcat 5.5 context.xml, how to configure the Host element

Posted by Markus Schönhaber <to...@list-post.mks-mail.de>.
jerrycat wrote:

> I understand that Tomcat 5.5 prefers that your web application comes with a
> context.xml file under the META-INF folder. 

OK.

> So I added a context.xml file under the META-INF folder of my web
> application, please have a look below. 
> 
> context.xml 
> [code] 
>    
> [/code] 

Looks very ... hm ... clean.

> Ok, that is good so far, but how do I configure the Host element. 
> 
> I mean how do you link a specific Host to a specific Context? 
> before, the Context element was a sub element of the Host element, now it is
> completely separated. 

Deploy your webapp to the directory you configured as appBase for the 
corresponding host.

> Host element in server.xml
> [code] 
>  
>  
> [/code] 

Rather clean also.

Regards
   mks

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