You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rajkumar Singh <ra...@digitas.com> on 2011/10/27 23:10:06 UTC

context.xml not being read

Hello,

I am not able to read the environment variable from the server.xml - those 
are also referenced in the META-INF/context.xml.

I am using tomcat version 6.0.29. The tomcat is deployed on the OS Linux

I am deploying my source code in some folder called 
/data2/www/xyz/htdocs/approot. I have pointed the server.xml to read from 
/data2/www/xyz/htdocs/approot as follows:

<Host name="xyz.company.com">
        <Context path="/" docBase="/data2/www/xyz/htdocs/approot" 
reloadable="true" debug="0" override="true" />
</Host>

Under the "approot" folder I have the WEB-INF and the META-INF folder. And 
under the META-INF folder I have the context.xml.

The server.xml has one environment variable as follows:

<Environment name="serverURLPrefix" override="false" 
type="java.lang.String" value="http://xyz.company.com"/>

And in the context.xml the same variable is referenced as

<Context path="/" reloadable="true" debug="0" override="true">
        <ResourceLink global="serverURLPrefix" name="serverURLPrefix" 
type="java.lang.String"/>
</Context>

Can please help me in understanding as to why the tomcat is not able to 
read the property "serverURLPrefix"?

Thanks
Raj

------------------------------------------------------------------------
Disclaimer 
The information in this email and any attachments may contain proprietary and confidential information that is intended for the addressee(s) only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, retention or use of the contents of this information is prohibited.  When addressed to our clients or vendors, any information contained in this e-mail or any attachments is subject to the terms and conditions in any governing contract. If you have received this e-mail in error, please immediately contact the sender and delete the e-mail.

RE: context.xml not being read

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com] 
> Subject: Re: context.xml not being read

> > <Host name="xyz.company.com">
> >        <Context path="/" docBase="/data2/www/xyz/htdocs/approot"
> > reloadable="true" debug="0" override="true" />
> > </Host>

> You choose to define it in server.xml and thus context.xml file is ignored.

And the OP chose to define it incorrectly; path="/" is never correct.

 - 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


Re: context.xml not being read

Posted by Pid * <pi...@pidster.com>.
On 28 Oct 2011, at 02:07, jilen <ji...@gmail.com> wrote:

> On 10/28/2011 06:45 AM, Rajkumar Singh wrote:
>> Hi Chuck,
>>
>> Once again appreciate your response.
>>
>> What I did was I created a WAR file and dropped it under the tomcat
>> webapps folder and started it. This helped in overcoming my problem.
>>
>> This process created conf/Catalina/[host]/[appName].xml and copied all the
>> property from my local META-INF/context.xml into the new [appName].xml.
>> This helped the tomcat in reading all the environment variables.
>>
>> Thank you everyone who replied to my mail. Please keep up the good work.
>>
>> Thanks
>> Raj
>>
>>
>>
>>
>> From:
>> "Caldarale, Charles R"<Ch...@unisys.com>
>> To:
>> Tomcat Users List<us...@tomcat.apache.org>
>> Date:
>> 10/27/2011 05:55 PM
>> Subject:
>> RE: context.xml not being read
>>
>>
>>
>>> From: Rajkumar Singh [mailto:rajkumar.singh@digitas.com]
>>> Subject: Re: context.xml not being read
>>> If the context.xml file is being ignored then why the variable that I
>> have
>>> defined in the server.xml is not being read? Should I delete the
>>> META-INF/context.xml file completely?
>> Having a<Context>  element in server.xml is strongly discouraged these
>> days.  Better to keep it in META-INF/context.xml of the webapp, or in
>> conf/Catalina/[host]/[appName].xml.  Regardless, you must have it in only
>> one place; having it in multiple places means the behavior is undefined.
>>
>> Note that if you want to define the default webapp, it should be named
>> ROOT (case sensitive).  You must not use path attribute when the<Context>
>> element is in META-INF/context.xml or in
>> conf/Catalina/[host]/[appName].xml.  Read the docs on the<Context>
>> element for more details.
>>
>>  - 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
>>
>>
>>
>> ------------------------------------------------------------------------
>> Disclaimer
>> The information in this email and any attachments may contain proprietary and confidential information that is intended for the addressee(s) only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, retention or use of the contents of this information is prohibited.  When addressed to our clients or vendors, any information contained in this e-mail or any attachments is subject to the terms and conditions in any governing contract. If you have received this e-mail in error, please immediately contact the sender and delete the e-mail.
>>
> This is the question i've asked before
>
> in org.apache.catalina.startup.HostConfig.deployWAR(ContextName, File, String)
> i found some code like these
>
> context.setName(cn.getName());
> context.setPath(cn.getPath());
> context.setWebappVersion(cn.getVersion());
> context.setDocBase(file);
> ...
> name and path attribute are override with the war name
> *So these attribute are not work. *

Seems like they work like tgey're supposed to, to me.


p

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


Re: context.xml not being read

Posted by jilen <ji...@gmail.com>.
On 10/29/2011 04:48 AM, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jilen,
>
> On 10/27/2011 9:06 PM, jilen wrote:
>> This is the question i've asked before
>>
>> in org.apache.catalina.startup.HostConfig.deployWAR(ContextName,
>> File, String) i found some code like these
>>
>> context.setName(cn.getName()); context.setPath(cn.getPath());
>> context.setWebappVersion(cn.getVersion());
>> context.setDocBase(file); ... name and path attribute are override
>> with the war name *So these attribute are not work. *
> You got an answer before. Did you not like the answer you got?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk6rFQsACgkQ9CaO5/Lv0PByZwCfcU+z22ji05sNrFISvjAFyGjS
> AXwAn0xZz16m0XTNUq0peYDCUeIta8f0
> =/zCh
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
No, the answer of my question is exactly detailed in the doc.
I just indicates that the context.xml is read actually, but some 
attributes in /META-INF/context.xml is overrided

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


Re: context.xml not being read

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

Jilen,

On 10/27/2011 9:06 PM, jilen wrote:
> This is the question i've asked before
> 
> in org.apache.catalina.startup.HostConfig.deployWAR(ContextName,
> File, String) i found some code like these
> 
> context.setName(cn.getName()); context.setPath(cn.getPath()); 
> context.setWebappVersion(cn.getVersion()); 
> context.setDocBase(file); ... name and path attribute are override
> with the war name *So these attribute are not work. *

You got an answer before. Did you not like the answer you got?

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

iEYEARECAAYFAk6rFQsACgkQ9CaO5/Lv0PByZwCfcU+z22ji05sNrFISvjAFyGjS
AXwAn0xZz16m0XTNUq0peYDCUeIta8f0
=/zCh
-----END PGP SIGNATURE-----

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


Re: context.xml not being read

Posted by jilen <ji...@gmail.com>.
On 10/28/2011 06:45 AM, Rajkumar Singh wrote:
> Hi Chuck,
>
> Once again appreciate your response.
>
> What I did was I created a WAR file and dropped it under the tomcat
> webapps folder and started it. This helped in overcoming my problem.
>
> This process created conf/Catalina/[host]/[appName].xml and copied all the
> property from my local META-INF/context.xml into the new [appName].xml.
> This helped the tomcat in reading all the environment variables.
>
> Thank you everyone who replied to my mail. Please keep up the good work.
>
> Thanks
> Raj
>
>
>
>
> From:
> "Caldarale, Charles R"<Ch...@unisys.com>
> To:
> Tomcat Users List<us...@tomcat.apache.org>
> Date:
> 10/27/2011 05:55 PM
> Subject:
> RE: context.xml not being read
>
>
>
>> From: Rajkumar Singh [mailto:rajkumar.singh@digitas.com]
>> Subject: Re: context.xml not being read
>> If the context.xml file is being ignored then why the variable that I
> have
>> defined in the server.xml is not being read? Should I delete the
>> META-INF/context.xml file completely?
> Having a<Context>  element in server.xml is strongly discouraged these
> days.  Better to keep it in META-INF/context.xml of the webapp, or in
> conf/Catalina/[host]/[appName].xml.  Regardless, you must have it in only
> one place; having it in multiple places means the behavior is undefined.
>
> Note that if you want to define the default webapp, it should be named
> ROOT (case sensitive).  You must not use path attribute when the<Context>
> element is in META-INF/context.xml or in
> conf/Catalina/[host]/[appName].xml.  Read the docs on the<Context>
> element for more details.
>
>   - 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
>
>
>
> ------------------------------------------------------------------------
> Disclaimer
> The information in this email and any attachments may contain proprietary and confidential information that is intended for the addressee(s) only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, retention or use of the contents of this information is prohibited.  When addressed to our clients or vendors, any information contained in this e-mail or any attachments is subject to the terms and conditions in any governing contract. If you have received this e-mail in error, please immediately contact the sender and delete the e-mail.
>
This is the question i've asked before

in org.apache.catalina.startup.HostConfig.deployWAR(ContextName, File, 
String)
i found some code like these

context.setName(cn.getName());
context.setPath(cn.getPath());
context.setWebappVersion(cn.getVersion());
context.setDocBase(file);
...
name and path attribute are override with the war name
*So these attribute are not work. *

RE: context.xml not being read

Posted by Rajkumar Singh <ra...@digitas.com>.
Hi Chuck,

Once again appreciate your response.

What I did was I created a WAR file and dropped it under the tomcat 
webapps folder and started it. This helped in overcoming my problem.

This process created conf/Catalina/[host]/[appName].xml and copied all the 
property from my local META-INF/context.xml into the new [appName].xml. 
This helped the tomcat in reading all the environment variables.

Thank you everyone who replied to my mail. Please keep up the good work.

Thanks
Raj




From:
"Caldarale, Charles R" <Ch...@unisys.com>
To:
Tomcat Users List <us...@tomcat.apache.org>
Date:
10/27/2011 05:55 PM
Subject:
RE: context.xml not being read



> From: Rajkumar Singh [mailto:rajkumar.singh@digitas.com] 
> Subject: Re: context.xml not being read

> If the context.xml file is being ignored then why the variable that I 
have 
> defined in the server.xml is not being read? Should I delete the 
> META-INF/context.xml file completely?

Having a <Context> element in server.xml is strongly discouraged these 
days.  Better to keep it in META-INF/context.xml of the webapp, or in 
conf/Catalina/[host]/[appName].xml.  Regardless, you must have it in only 
one place; having it in multiple places means the behavior is undefined.

Note that if you want to define the default webapp, it should be named 
ROOT (case sensitive).  You must not use path attribute when the <Context> 
element is in META-INF/context.xml or in 
conf/Catalina/[host]/[appName].xml.  Read the docs on the <Context> 
element for more details.

 - 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



------------------------------------------------------------------------
Disclaimer 
The information in this email and any attachments may contain proprietary and confidential information that is intended for the addressee(s) only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, retention or use of the contents of this information is prohibited.  When addressed to our clients or vendors, any information contained in this e-mail or any attachments is subject to the terms and conditions in any governing contract. If you have received this e-mail in error, please immediately contact the sender and delete the e-mail.

RE: context.xml not being read

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rajkumar Singh [mailto:rajkumar.singh@digitas.com] 
> Subject: Re: context.xml not being read

> If the context.xml file is being ignored then why the variable that I have 
> defined in the server.xml is not being read? Should I delete the 
> META-INF/context.xml file completely?

Having a <Context> element in server.xml is strongly discouraged these days.  Better to keep it in META-INF/context.xml of the webapp, or in conf/Catalina/[host]/[appName].xml.  Regardless, you must have it in only one place; having it in multiple places means the behavior is undefined.

Note that if you want to define the default webapp, it should be named ROOT (case sensitive).  You must not use path attribute when the <Context> element is in META-INF/context.xml or in conf/Catalina/[host]/[appName].xml.  Read the docs on the <Context> element for more details.

 - 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


Re: context.xml not being read

Posted by Rajkumar Singh <ra...@digitas.com>.
Thank you for replying.

If the context.xml file is being ignored then why the variable that I have 
defined in the server.xml is not being read? Should I delete the 
META-INF/context.xml file completely?




From:
Konstantin Kolinko <kn...@gmail.com>
To:
Tomcat Users List <us...@tomcat.apache.org>
Date:
10/27/2011 05:33 PM
Subject:
Re: context.xml not being read



2011/10/28 Rajkumar Singh <ra...@digitas.com>:
> Hello,
>
> I am not able to read the environment variable from the server.xml - 
those
> are also referenced in the META-INF/context.xml.
>
> I am using tomcat version 6.0.29. The tomcat is deployed on the OS Linux
>
> I am deploying my source code in some folder called
> /data2/www/xyz/htdocs/approot. I have pointed the server.xml to read 
from
> /data2/www/xyz/htdocs/approot as follows:
>
> <Host name="xyz.company.com">
>        <Context path="/" docBase="/data2/www/xyz/htdocs/approot"
> reloadable="true" debug="0" override="true" />
> </Host>
>
> Under the "approot" folder I have the WEB-INF and the META-INF folder. 
And
> under the META-INF folder I have the context.xml.
>
> The server.xml has one environment variable as follows:
>
> <Environment name="serverURLPrefix" override="false"
> type="java.lang.String" value="http://xyz.company.com"/>
>
> And in the context.xml the same variable is referenced as
>
> <Context path="/" reloadable="true" debug="0" override="true">
>        <ResourceLink global="serverURLPrefix" name="serverURLPrefix"
> type="java.lang.String"/>
> </Context>
>
> Can please help me in understanding as to why the tomcat is not able to
> read the property "serverURLPrefix"?
>

This behaviour is by design. The <Context> element can be defined only 
once.

You choose to define it in server.xml and thus context.xml file is 
ignored.

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



------------------------------------------------------------------------
Disclaimer 
The information in this email and any attachments may contain proprietary and confidential information that is intended for the addressee(s) only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, retention or use of the contents of this information is prohibited.  When addressed to our clients or vendors, any information contained in this e-mail or any attachments is subject to the terms and conditions in any governing contract. If you have received this e-mail in error, please immediately contact the sender and delete the e-mail.

Re: context.xml not being read

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/10/28 Rajkumar Singh <ra...@digitas.com>:
> Hello,
>
> I am not able to read the environment variable from the server.xml - those
> are also referenced in the META-INF/context.xml.
>
> I am using tomcat version 6.0.29. The tomcat is deployed on the OS Linux
>
> I am deploying my source code in some folder called
> /data2/www/xyz/htdocs/approot. I have pointed the server.xml to read from
> /data2/www/xyz/htdocs/approot as follows:
>
> <Host name="xyz.company.com">
>        <Context path="/" docBase="/data2/www/xyz/htdocs/approot"
> reloadable="true" debug="0" override="true" />
> </Host>
>
> Under the "approot" folder I have the WEB-INF and the META-INF folder. And
> under the META-INF folder I have the context.xml.
>
> The server.xml has one environment variable as follows:
>
> <Environment name="serverURLPrefix" override="false"
> type="java.lang.String" value="http://xyz.company.com"/>
>
> And in the context.xml the same variable is referenced as
>
> <Context path="/" reloadable="true" debug="0" override="true">
>        <ResourceLink global="serverURLPrefix" name="serverURLPrefix"
> type="java.lang.String"/>
> </Context>
>
> Can please help me in understanding as to why the tomcat is not able to
> read the property "serverURLPrefix"?
>

This behaviour is by design. The <Context> element can be defined only once.

You choose to define it in server.xml and thus context.xml file is ignored.

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