You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2005/06/25 01:24:01 UTC

Strange error-page behavior

Hello all:

I have this directives in my web.xml file:
  <!-- Application wide error page -->  
  <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error.do</location>
  </error-page>

This is supposed to invoke this action in the struts config file:
    <action path="/error" type="action.ErrorAction">
      <forward name="errorPage" path="/errorPage.do" redirect="true"/> 
    </action>
    <action path="/errorPage" forward="page.error"/>

The page.error outputs a generic error page.

When I throw an exception from an action class, it works as expected,
invoking the ErrorAction and then giving me the error page.

But, when I throw an exceptio from a JSP page, it does not call the
action and I get this exception in the tomcat logs:

2005-06-24 18:20:42 org.apache.catalina.core.StandardHostValve@129c445:
Exception Processing ErrorPage[exceptionType=java.lang.Throwable,
location=/error.do]
java.lang.IllegalStateException
        at org.apache.coyote.Response.reset(Response.java:296)
        at
org.apache.coyote.tomcat5.CoyoteResponse.reset(CoyoteResponse.java:631)
        at
org.apache.coyote.tomcat5.CoyoteResponse.reset(CoyoteResponse.java:887)
        at
org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:389
)
        at
org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:
225)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145
)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117
)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:296)
        at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:372)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:694)
        at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:626)
        at
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:807)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:644)
        at java.lang.Thread.run(Thread.java:595)

What can I do to fix this?

Thanks,
	Neil

--
Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com


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


Re: Strange error-page behavior

Posted by Laurie Harper <la...@holoweb.net>.
I don't know of a way of setting the response buffer size globally either, but setting it on a per-page basis is probably a good idea anyway; that way you can set it larger for heavier pages without incurring the overhead of a larger buffer where it's not needed.

L.

Martin Gainty wrote:

> Neil-
> Best that I can surmise is setBufferSize(int size) method in the 
> ServletResponse interface
> Anyone else?
> Martin-
> ----- Original Message ----- From: "Neil Aggarwal" 
> <ne...@JAMMConsulting.com>
> To: "'Struts Users Mailing List'" <us...@struts.apache.org>
> Sent: Friday, June 24, 2005 9:09 PM
> Subject: RE: Strange error-page behavior
> 
> 
>> Laurie:
>>
>> Is there an app-wide way to set the buffer size or do I need to
>> put a page buffer directive in each of my JSPs?
>>
>> Thanks,
>> Neil
>>
>>
>> -- 
>> Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
>> FREE! Valuable info on how your business can reduce operating costs by
>> 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com
>>
>>> -----Original Message-----
>>> From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
>>> Sent: Friday, June 24, 2005 7:32 PM
>>> To: user@struts.apache.org
>>> Subject: Re: Strange error-page behavior
>>>
>>>
>>> The problem is that by the time the error occurs in your JSP,
>>> the response has already been committed. When Tomcat tries to
>>> issue the redirect to the error page, it fails. Your only
>>> recouse is to increase the size of the response buffer. To be
>>> robust, the buffer would need to be at least as large as your
>>> heaviest page... Not great, but about all you can do.
>>>
>>> BTW, using a Struts action for the error page should be fine
>>> I think; a 'resource' in a web application is anything
>>> addressed by a URL, effectively. Just make sure that your
>>> error page processing is robust -- i.e. it needs to catch and
>>> handle any exceptions itself.
>>>
>>> L.
>>>
>>> Neil Aggarwal wrote:
>>>
>>> > Wendy:
>>> >
>>> > I tried setting my error page directive to:
>>> >   <error-page>
>>> >     <exception-type>java.lang.Throwable</exception-type>
>>> >     <location>/errorPage.jsp</location>
>>> >   </error-page>
>>> >
>>> > I am still getting an IllegalStateException.
>>> >
>>> > That seems weird to me.
>>> >
>>> > Neil
>>> >
>>> >
>>> > --
>>> > Neil Aggarwal, JAMM Consulting, (214) 986-3533,
>>> www.JAMMConsulting.com
>>> > FREE! Valuable info on how your business can reduce
>>> operating costs by
>>> > 17% or more in 6 months or less!
>>> http://newsletter.JAMMConsulting.com
>>> >
>>> >
>>> >>-----Original Message-----
>>> >>From: Wendy Smoak [mailto:java@wendysmoak.com]
>>> >>Sent: Friday, June 24, 2005 6:53 PM
>>> >>To: Struts Users Mailing List
>>> >>Subject: Re: Strange error-page behavior
>>> >>
>>> >>
>>> >>From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
>>> >>
>>> >>>The reason I need to execute code is for me to send an error report
>>> >>>to the site admin.
>>> >>
>>> >>Have you tried using an actual file (.jsp or .html) that does
>>> >>nothing but
>>> >>forward or redirect to the Struts action?  Or perhaps... can
>>> >>you just call
>>> >>the whatever-sends-the-email from the JSP?
>>> >>
>>> >>Let me know if you get <location> to work with a path that's
>>> >>not an actual
>>> >>file, I haven't been able to find anything definitive that
>>> >>says you can't,
>>> >>but it never worked for me.
>>> >>
>>> >>-- >>Wendy Smoak
>>> >>
>>> >>
>>> >>------------------------------------------------------------
>>> ---------
>>> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >>For additional commands, e-mail: user-help@struts.apache.org
>>> >>
>>>
>>>
>>> -- 
>>> Laurie, Open Source advocate, Java geek and novice blogger:
>>> http://www.holoweb.net/~laurie/
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/


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


Re: Strange error-page behavior

Posted by Martin Gainty <mg...@hotmail.com>.
Neil-
Best that I can surmise is setBufferSize(int size) method in the 
ServletResponse interface
Anyone else?
Martin-
----- Original Message ----- 
From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>
Sent: Friday, June 24, 2005 9:09 PM
Subject: RE: Strange error-page behavior


> Laurie:
>
> Is there an app-wide way to set the buffer size or do I need to
> put a page buffer directive in each of my JSPs?
>
> Thanks,
> Neil
>
>
> --
> Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
> FREE! Valuable info on how your business can reduce operating costs by
> 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com
>
>> -----Original Message-----
>> From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
>> Sent: Friday, June 24, 2005 7:32 PM
>> To: user@struts.apache.org
>> Subject: Re: Strange error-page behavior
>>
>>
>> The problem is that by the time the error occurs in your JSP,
>> the response has already been committed. When Tomcat tries to
>> issue the redirect to the error page, it fails. Your only
>> recouse is to increase the size of the response buffer. To be
>> robust, the buffer would need to be at least as large as your
>> heaviest page... Not great, but about all you can do.
>>
>> BTW, using a Struts action for the error page should be fine
>> I think; a 'resource' in a web application is anything
>> addressed by a URL, effectively. Just make sure that your
>> error page processing is robust -- i.e. it needs to catch and
>> handle any exceptions itself.
>>
>> L.
>>
>> Neil Aggarwal wrote:
>>
>> > Wendy:
>> >
>> > I tried setting my error page directive to:
>> >   <error-page>
>> >     <exception-type>java.lang.Throwable</exception-type>
>> >     <location>/errorPage.jsp</location>
>> >   </error-page>
>> >
>> > I am still getting an IllegalStateException.
>> >
>> > That seems weird to me.
>> >
>> > Neil
>> >
>> >
>> > --
>> > Neil Aggarwal, JAMM Consulting, (214) 986-3533,
>> www.JAMMConsulting.com
>> > FREE! Valuable info on how your business can reduce
>> operating costs by
>> > 17% or more in 6 months or less!
>> http://newsletter.JAMMConsulting.com
>> >
>> >
>> >>-----Original Message-----
>> >>From: Wendy Smoak [mailto:java@wendysmoak.com]
>> >>Sent: Friday, June 24, 2005 6:53 PM
>> >>To: Struts Users Mailing List
>> >>Subject: Re: Strange error-page behavior
>> >>
>> >>
>> >>From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
>> >>
>> >>>The reason I need to execute code is for me to send an error report
>> >>>to the site admin.
>> >>
>> >>Have you tried using an actual file (.jsp or .html) that does
>> >>nothing but
>> >>forward or redirect to the Struts action?  Or perhaps... can
>> >>you just call
>> >>the whatever-sends-the-email from the JSP?
>> >>
>> >>Let me know if you get <location> to work with a path that's
>> >>not an actual
>> >>file, I haven't been able to find anything definitive that
>> >>says you can't,
>> >>but it never worked for me.
>> >>
>> >>-- 
>> >>Wendy Smoak
>> >>
>> >>
>> >>------------------------------------------------------------
>> ---------
>> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>For additional commands, e-mail: user-help@struts.apache.org
>> >>
>>
>>
>> -- 
>> Laurie, Open Source advocate, Java geek and novice blogger:
>> http://www.holoweb.net/~laurie/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

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


RE: Strange error-page behavior

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Laurie:

Is there an app-wide way to set the buffer size or do I need to
put a page buffer directive in each of my JSPs?

Thanks,
	Neil


--
Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
> Sent: Friday, June 24, 2005 7:32 PM
> To: user@struts.apache.org
> Subject: Re: Strange error-page behavior
> 
> 
> The problem is that by the time the error occurs in your JSP, 
> the response has already been committed. When Tomcat tries to 
> issue the redirect to the error page, it fails. Your only 
> recouse is to increase the size of the response buffer. To be 
> robust, the buffer would need to be at least as large as your 
> heaviest page... Not great, but about all you can do.
> 
> BTW, using a Struts action for the error page should be fine 
> I think; a 'resource' in a web application is anything 
> addressed by a URL, effectively. Just make sure that your 
> error page processing is robust -- i.e. it needs to catch and 
> handle any exceptions itself.
> 
> L.
> 
> Neil Aggarwal wrote:
> 
> > Wendy:
> > 
> > I tried setting my error page directive to:
> >   <error-page>
> >     <exception-type>java.lang.Throwable</exception-type>
> >     <location>/errorPage.jsp</location>
> >   </error-page>
> > 
> > I am still getting an IllegalStateException.
> > 
> > That seems weird to me.
> > 
> > 	Neil
> > 
> > 
> > --
> > Neil Aggarwal, JAMM Consulting, (214) 986-3533, 
> www.JAMMConsulting.com
> > FREE! Valuable info on how your business can reduce 
> operating costs by
> > 17% or more in 6 months or less! 
> http://newsletter.JAMMConsulting.com
> > 
> > 
> >>-----Original Message-----
> >>From: Wendy Smoak [mailto:java@wendysmoak.com] 
> >>Sent: Friday, June 24, 2005 6:53 PM
> >>To: Struts Users Mailing List
> >>Subject: Re: Strange error-page behavior
> >>
> >>
> >>From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
> >>
> >>>The reason I need to execute code is for me to send an error report
> >>>to the site admin.
> >>
> >>Have you tried using an actual file (.jsp or .html) that does 
> >>nothing but
> >>forward or redirect to the Struts action?  Or perhaps... can 
> >>you just call
> >>the whatever-sends-the-email from the JSP?
> >>
> >>Let me know if you get <location> to work with a path that's 
> >>not an actual
> >>file, I haven't been able to find anything definitive that 
> >>says you can't,
> >>but it never worked for me.
> >>
> >>-- 
> >>Wendy Smoak
> >>
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> 
> 
> -- 
> Laurie, Open Source advocate, Java geek and novice blogger:
> http://www.holoweb.net/~laurie/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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


Re: Strange error-page behavior

Posted by Laurie Harper <la...@holoweb.net>.
The problem is that by the time the error occurs in your JSP, the response has already been committed. When Tomcat tries to issue the redirect to the error page, it fails. Your only recouse is to increase the size of the response buffer. To be robust, the buffer would need to be at least as large as your heaviest page... Not great, but about all you can do.

BTW, using a Struts action for the error page should be fine I think; a 'resource' in a web application is anything addressed by a URL, effectively. Just make sure that your error page processing is robust -- i.e. it needs to catch and handle any exceptions itself.

L.

Neil Aggarwal wrote:

> Wendy:
> 
> I tried setting my error page directive to:
>   <error-page>
>     <exception-type>java.lang.Throwable</exception-type>
>     <location>/errorPage.jsp</location>
>   </error-page>
> 
> I am still getting an IllegalStateException.
> 
> That seems weird to me.
> 
> 	Neil
> 
> 
> --
> Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
> FREE! Valuable info on how your business can reduce operating costs by
> 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com
> 
> 
>>-----Original Message-----
>>From: Wendy Smoak [mailto:java@wendysmoak.com] 
>>Sent: Friday, June 24, 2005 6:53 PM
>>To: Struts Users Mailing List
>>Subject: Re: Strange error-page behavior
>>
>>
>>From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
>>
>>>The reason I need to execute code is for me to send an error report
>>>to the site admin.
>>
>>Have you tried using an actual file (.jsp or .html) that does 
>>nothing but
>>forward or redirect to the Struts action?  Or perhaps... can 
>>you just call
>>the whatever-sends-the-email from the JSP?
>>
>>Let me know if you get <location> to work with a path that's 
>>not an actual
>>file, I haven't been able to find anything definitive that 
>>says you can't,
>>but it never worked for me.
>>
>>-- 
>>Wendy Smoak
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>


-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/


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


RE: Strange error-page behavior

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Wendy:

I tried setting my error page directive to:
  <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/errorPage.jsp</location>
  </error-page>

I am still getting an IllegalStateException.

That seems weird to me.

	Neil


--
Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com

> -----Original Message-----
> From: Wendy Smoak [mailto:java@wendysmoak.com] 
> Sent: Friday, June 24, 2005 6:53 PM
> To: Struts Users Mailing List
> Subject: Re: Strange error-page behavior
> 
> 
> From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
> 
> > The reason I need to execute code is for me to send an error report
> > to the site admin.
> 
> Have you tried using an actual file (.jsp or .html) that does 
> nothing but
> forward or redirect to the Struts action?  Or perhaps... can 
> you just call
> the whatever-sends-the-email from the JSP?
> 
> Let me know if you get <location> to work with a path that's 
> not an actual
> file, I haven't been able to find anything definitive that 
> says you can't,
> but it never worked for me.
> 
> -- 
> Wendy Smoak
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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


Re: Strange error-page behavior

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Neil Aggarwal" <ne...@JAMMConsulting.com>

> The reason I need to execute code is for me to send an error report
> to the site admin.

Have you tried using an actual file (.jsp or .html) that does nothing but
forward or redirect to the Struts action?  Or perhaps... can you just call
the whatever-sends-the-email from the JSP?

Let me know if you get <location> to work with a path that's not an actual
file, I haven't been able to find anything definitive that says you can't,
but it never worked for me.

-- 
Wendy Smoak


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


RE: Strange error-page behavior

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Wendy:

The reason I need to execute code is for me to send an error report
to the site admin.

Thanks,
	Neil


--
Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com

> -----Original Message-----
> From: Wendy Smoak [mailto:java@wendysmoak.com] 
> Sent: Friday, June 24, 2005 6:40 PM
> To: Struts Users Mailing List
> Subject: Re: Strange error-page behavior
> 
> 
> From: "Neil Aggarwal" <ne...@JAMMConsulting.com>
> 
> > I have this directives in my web.xml file:
> >   <!-- Application wide error page -->
> >   <error-page>
> >     <exception-type>java.lang.Throwable</exception-type>
> >   <location>/error.do</location>
> > <error-page>
> 
> Having dealt with this recently, I'm fairly sure the 
> <location> has to be
> something that the container can actually locate, read, and 
> send out to the
> browser.
> 
> I can't find anything in the Servlet 2.3 specification that 
> actually *says*
> it has to be a physical file, but that's been my experience, and the
> comments in the DTD (which refers to "a resource in the web
> application" )seem to imply it.
> 
> Consider this... by the time something *that* bad has happened, do you
> really want to try to execute code before you can show 
> something to the
> user?
> 
> HTH,
> -- 
> Wendy Smoak
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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


Re: Strange error-page behavior

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Neil Aggarwal" <ne...@JAMMConsulting.com>

> I have this directives in my web.xml file:
>   <!-- Application wide error page -->
>   <error-page>
>     <exception-type>java.lang.Throwable</exception-type>
>   <location>/error.do</location>
> <error-page>

Having dealt with this recently, I'm fairly sure the <location> has to be
something that the container can actually locate, read, and send out to the
browser.

I can't find anything in the Servlet 2.3 specification that actually *says*
it has to be a physical file, but that's been my experience, and the
comments in the DTD (which refers to "a resource in the web
application" )seem to imply it.

Consider this... by the time something *that* bad has happened, do you
really want to try to execute code before you can show something to the
user?

HTH,
-- 
Wendy Smoak









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