You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jean-François Ménard <je...@gmail.com> on 2008/07/08 00:15:26 UTC

Problem with Context Parameters

Hi all,

Using Tomcat 6.0.13, I try to define some context parameters in my
context file (in conf/Cataline/localhost/<app_name>.xml) as described
in the documentation
(http://tomcat.apache.org/tomcat-6.0-doc/config/context.html) but it
simply doesn't work!  I can see the parameters defined in my web.xml,
but not those defined in my context file.

Is that supposed to work at all?

Example:

<Context path="application">

  <Parameter name ="aParameterName" value="aValue" />

</Context>

Shouldn't the parameter be visible by the servlet context? ex.
context.getInitParameter("aParameterName")

Am I missing something, or Tomcat is not working as described in the doc?

---------------------------------------------------------------------
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: Problem with Context Parameters

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

Jean-François,

Jean-François Ménard wrote:
| As a side note, if I deploy the app in a standalone Tomcat, the
| problem appear, but if I use the app with eclipse wtp, everything is
| fine.

Hmm... I suspect that you are not using the context.xml file you think
you are using when Tomcat is standalone. Triple-check all files and
paths for the standalone setup. Also, try blowing-away your work
directory's contents just in case something got stuck in cache-land.

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

iEYEARECAAYFAkhzjcoACgkQ9CaO5/Lv0PBC+gCgpyyaZ2H0EZ8vCMclprchCMLb
ZycAoIbhqbGNgAxCqo56VzLv3EbYz1By
=VBTZ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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: Problem with Context Parameters

Posted by Jean-François Ménard <je...@gmail.com>.
Thanks all for your help.

It's quite embarrassing, but my problem was that I had "<context"
(with a lower case c) instead of "<Context" (with a upper case C)...

So Tomcat was simply ignoring my context file...

2008/7/8 Caldarale, Charles R <Ch...@unisys.com>:
>> From: Jean-François Ménard [mailto:jeanfrancoismenard@gmail.com]
>> Subject: Re: Problem with Context Parameters
>>
>> Context file (conf/Catalina/localhost/app.xml:
>> <Context path="app">
>>   <Parameter name ="paramInContext" value="ParamValue" />
>> </Context>
>
> Just a side note: the path attribute is not allowed in the above scenario; the name of the .xml file defines the URL path to the webapp.
>
>  - 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 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: Problem with Context Parameters

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jean-François Ménard [mailto:jeanfrancoismenard@gmail.com]
> Subject: Re: Problem with Context Parameters
>
> Context file (conf/Catalina/localhost/app.xml:
> <Context path="app">
>   <Parameter name ="paramInContext" value="ParamValue" />
> </Context>

Just a side note: the path attribute is not allowed in the above scenario; the name of the .xml file defines the URL path to the webapp.

 - 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 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: Problem with Context Parameters

Posted by Jean-François Ménard <je...@gmail.com>.
Thanks for your reply!

Comments inlined

2008/7/8 Christopher Schultz <ch...@christopherschultz.net>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jean-François,
>
> Jean-François Ménard wrote:
> | Using Tomcat 6.0.13, I try to define some context parameters in my
> | context file (in conf/Cataline/localhost/<app_name>.xml)
>
> That should be conf/Catalina/localhost/<app_name>.xml

Yes, it is, just a typo in the message...

>
> | as described in the documentation
> | (http://tomcat.apache.org/tomcat-6.0-doc/config/context.html) but it
> | simply doesn't work!  I can see the parameters defined in my web.xml,
> | but not those defined in my context file.
>
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Context+Parameters
> indicates that <Parameter> in context.xml ought to be equivalent to
> <context-param> in web.xml.
>
> Have you defined the same parameter in both files? If so, you should
> take care not to set override="false", or your web.xml version will not
> be clobbered by the context.xml version.

No, the parameter is only in the context file, not in both.

>
> | Shouldn't the parameter be visible by the servlet context? ex.
> | context.getInitParameter("aParameterName")
>
> Yes, it should. Could you provide a sample context.xml and servlet that
> do not work together?
>

Ok, here it is.

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<display-name>App</display-name>
	
	<context-param>
		<param-name>paramInWebXml</param-name>
		<param-value>ParamValue</param-value>
	</context-param>

...

</web-app>

Context file (conf/Catalina/localhost/app.xml:

<Context path="app">

  <Parameter name ="paramInContext" value="ParamValue" />

</Context>

In my app, I can see the parameter defined in web.xml, not the one in
the context file...

As a side note, if I deploy the app in a standalone Tomcat, the
problem appear, but if I use the app with eclipse wtp, everything is
fine.

---------------------------------------------------------------------
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: Problem with Context Parameters

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

Jean-François,

Jean-François Ménard wrote:
| Using Tomcat 6.0.13, I try to define some context parameters in my
| context file (in conf/Cataline/localhost/<app_name>.xml)

That should be conf/Catalina/localhost/<app_name>.xml

| as described in the documentation
| (http://tomcat.apache.org/tomcat-6.0-doc/config/context.html) but it
| simply doesn't work!  I can see the parameters defined in my web.xml,
| but not those defined in my context file.

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Context+Parameters
indicates that <Parameter> in context.xml ought to be equivalent to
<context-param> in web.xml.

Have you defined the same parameter in both files? If so, you should
take care not to set override="false", or your web.xml version will not
be clobbered by the context.xml version.

| Shouldn't the parameter be visible by the servlet context? ex.
| context.getInitParameter("aParameterName")

Yes, it should. Could you provide a sample context.xml and servlet that
do not work together?

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

iEYEARECAAYFAkhzYP4ACgkQ9CaO5/Lv0PCqxgCfV9Alm+k6ccE9kfeEeaU5+K5R
7MkAnil85SMgKTkHNi8yFLYpHUOua9dF
=p/xO
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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