You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Melvin <me...@gmail.com> on 2018/12/20 06:44:26 UTC

Context specific context.xml not loading.

Hello All,

Just came across a problem today. Hope someone will clarify it.

Tomcat 9.0.13.
I wanted to customize ErrorReportValve by setting showReport="false"
showServerInfo="false".

Below is the META-INF/context.xml -
<Context>
<Valve className="org.apache.catalina.valves.ErrorReportValve"
showReport="false" showServerInfo="false" />
</Context>

It works fine for any internal server error produced or exceptions thrown.
But for the case when the browser sends unencoded characters the URL
becomes invalid and Exception is thrown and stacktrace is shown in the
browser.
When I give this valve in server.xml. It works fine. No issues. No
stacktrace is shown on the browser when sending unencoded characters. When
I give it in my context it fails only for this case.

Can anyone please help me on this.
Thanks in advance for your help.
Regards,
Melvin A

Re: Context specific context.xml not loading.

Posted by Melvin <me...@gmail.com>.
Ryan Palmer,

CATALINA_BASE/conf/Catalina/localhost/ directory is empty. Also, I haven't
given any context in server.xml either.

Regards,
Melvin A


On Thu, Dec 20, 2018 at 1:53 PM Ryan Palmer <ry...@hotmail.com> wrote:

> Melvin,
>
> Do you have any context.xml for this context in the
> CATALINA_BASE/conf/Catalina/localhost/ directory? It may be overriding your
> META-INF/context.xml
>
> -Ryan
> On Dec 19, 2018, at 10:45 PM, Melvin <melvindoss@gmail.com<mailto:
> melvindoss@gmail.com>> wrote:
> Hello All,
>
> Just came across a problem today. Hope someone will clarify it.
>
> Tomcat 9.0.13.
> I wanted to customize ErrorReportValve by setting showReport="false"
> showServerInfo="false".
>
> Below is the META-INF/context.xml -
> <Context>
> <Valve className="org.apache.catalina.valves.ErrorReportValve"
> showReport="false" showServerInfo="false" />
> </Context>
>
> It works fine for any internal server error produced or exceptions thrown.
> But for the case when the browser sends unencoded characters the URL
> becomes invalid and Exception is thrown and stacktrace is shown in the
> browser.
> When I give this valve in server.xml. It works fine. No issues. No
> stacktrace is shown on the browser when sending unencoded characters. When
> I give it in my context it fails only for this case.
>
> Can anyone please help me on this.
> Thanks in advance for your help.
> Regards,
> Melvin A
>

Re: Context specific context.xml not loading.

Posted by Ryan Palmer <ry...@hotmail.com>.
Melvin,

Do you have any context.xml for this context in the CATALINA_BASE/conf/Catalina/localhost/ directory? It may be overriding your META-INF/context.xml

-Ryan
On Dec 19, 2018, at 10:45 PM, Melvin <me...@gmail.com>> wrote:
Hello All,

Just came across a problem today. Hope someone will clarify it.

Tomcat 9.0.13.
I wanted to customize ErrorReportValve by setting showReport="false" showServerInfo="false".

Below is the META-INF/context.xml -
<Context>
<Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" />
</Context>

It works fine for any internal server error produced or exceptions thrown. But for the case when the browser sends unencoded characters the URL becomes invalid and Exception is thrown and stacktrace is shown in the browser.
When I give this valve in server.xml. It works fine. No issues. No stacktrace is shown on the browser when sending unencoded characters. When I give it in my context it fails only for this case.

Can anyone please help me on this.
Thanks in advance for your help.
Regards,
Melvin A

Re: Context specific context.xml not loading.

Posted by Melvin <me...@gmail.com>.
ThankYou Mark.

Regards,
Melvin A


On Thu, Dec 20, 2018 at 2:51 PM Mark Thomas <ma...@apache.org> wrote:

> On 20/12/2018 06:44, Melvin wrote:
> > Hello All,
> >
> > Just came across a problem today. Hope someone will clarify it.
> >
> > Tomcat 9.0.13.
> > I wanted to customize ErrorReportValve by setting showReport="false"
> > showServerInfo="false".
> >
> > Below is the META-INF/context.xml -
> > <Context>
> > <Valve className="org.apache.catalina.valves.ErrorReportValve"
> > showReport="false" showServerInfo="false" />
> > </Context>
> >
> > It works fine for any internal server error produced or exceptions
> > thrown. But for the case when the browser sends unencoded characters the
> > URL becomes invalid and Exception is thrown and stacktrace is shown in
> > the browser.
> > When I give this valve in server.xml. It works fine. No issues. No
> > stacktrace is shown on the browser when sending unencoded characters.
> > When I give it in my context it fails only for this case.
> >
> > Can anyone please help me on this.
>
> You are configuring the Valve on different elements. In server.xml you
> are configuring it on the Host. In context.xml you are configuring it
> for a single web application.
>
> If the URL is invalid then the request will never be mapped to a web
> application so the ErrorReportVlave on the default Host will be used.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Context specific context.xml not loading.

Posted by Mark Thomas <ma...@apache.org>.
On 20/12/2018 06:44, Melvin wrote:
> Hello All,
> 
> Just came across a problem today. Hope someone will clarify it.
> 
> Tomcat 9.0.13.
> I wanted to customize ErrorReportValve by setting showReport="false"
> showServerInfo="false".
> 
> Below is the META-INF/context.xml - 
> <Context>
> <Valve className="org.apache.catalina.valves.ErrorReportValve"
> showReport="false" showServerInfo="false" />
> </Context>
> 
> It works fine for any internal server error produced or exceptions
> thrown. But for the case when the browser sends unencoded characters the
> URL becomes invalid and Exception is thrown and stacktrace is shown in
> the browser. 
> When I give this valve in server.xml. It works fine. No issues. No
> stacktrace is shown on the browser when sending unencoded characters.
> When I give it in my context it fails only for this case.
> 
> Can anyone please help me on this.

You are configuring the Valve on different elements. In server.xml you
are configuring it on the Host. In context.xml you are configuring it
for a single web application.

If the URL is invalid then the request will never be mapped to a web
application so the ErrorReportVlave on the default Host will be used.

Mark

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