0

Error handling exception

asked 2012-02-17 10:13:48 +0800

Neus gravatar image Neus
1415 14

Hi,
Following this http://books.zkoss.org/wiki/ZK_Developer's_Reference/UI_Patterns/Error_Handling I declared both in zk.xml and web.xml the error-page to customize AU Requests exceptions and zul Loading Exceptions respectively.
But if both are declared after the exception is thrown and the error-page is shown another exception appears

ADVERTENCIA: Failed to load the error page: /error.zul
java.lang.IllegalStateException: getOutputStream() ya ha sido llamado para esta respuesta
	at org.apache.catalina.connector.Response.getWriter(Response.java:633)
	at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:214)
	at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
	at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:167)
	at org.zkoss.zk.ui.http.DHtmlLayoutServlet.handleError(DHtmlLayoutServlet.java:266)
	at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:137)
	at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doPost(DHtmlLayoutServlet.java:148)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
	at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:450)
	at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:399)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:191)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

If error-page is only added to one configuration file (no matter wich) it doesn't happen.

It means there's another way to handle both exceptions type?

Thank you!

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2012-02-21 03:12:24 +0800

matthewgo gravatar image matthewgo
375

Hi Neus,
I declared both in zk.xml and web.xml, and works well.

zk.xml:

<zk>
	<error-page>
		<exception-type>java.lang.Throwable</exception-type>
		<location>/WEB-INF/sys/error.zul</location>
	</error-page>
</zk>

web.xml:

 
       ..........
       ...........
        <error-page>
		<exception-type>java.lang.Throwable</exception-type>
		<location>/WEB-INF/sys/error.zul</location>
	</error-page>
</web-app>

error.zul:

<window title="Error ${requestScope['javax.servlet.error.status_code']}">
    Cause: ${requestScope['javax.servlet.error.message']}    
</window>

test1.zul:

<button label="Cause Error" onClick='throw new NullPointerException("Unknown Value")'/>

test2.zul:

<zk>
      <ii>
      </ii>
</zk>


My zk version is 5.0.10.
Could you provide more infomation?
Thank you.

link publish delete flag offensive edit

answered 2012-02-21 08:32:57 +0800

Neus gravatar image Neus
1415 14

I use ZK 6 but it also happened before I updated.
zk.xml:

<error-page>
	<exception-type>java.lang.Throwable</exception-type>
	<location>/error.zul</location>
</error-page>  

web.xml:

<error-page>
	<exception-type>java.lang.Throwable</exception-type>
	<location>/error.zul</location>
</error-page>  

And this is error.zul:

<?page title="Pagina de Errores" contentType="text/html;charset=UTF-8"?>
<!-- <?init class="org.sts.generales.EventosAplicacion.IniciarPagina"?> -->

<zk xmlns="http://www.zkoss.org/2005/zul"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
	<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zscript>
	<![CDATA[//@IMPORT
	    import org.sts.recursosComunes.conexionesFuentesDatos.*;
	    import org.sts.recursosComunes.accesoDatos.Clase;
	   	import org.sts.generales.Herramientas.*;
	]]>
	Clase cEntidad;
	PoolConexiones pool = null;
		
	<![CDATA[
		//@DECLARATION
		// Liberamos los recursos que se hayan podido quedar colgados al dar error
		// Limpiamos la conexion y desbloqueamos el cEntidad
		private void LiberarRecursos(){
			if(desktop.hasAttribute("cEntidad")){
				cEntidad = (Clase)desktop.getAttribute("cEntidad");
				// Desbloqueamos el registro
				cEntidad.DesBloquearRegistro();
			}
		}
	]]>			
</zscript>
<window title="Error ${requestScope['javax.servlet.error.status_code']}" border="normal" mode="modal">
		
<!-- 		<caption id="TituloErrorPropio" label="_Error"/> -->
	<vbox id="CapaExcepcion">
		<separator />
		<separator />
		<div sclass="z-messagebox" width="100%">
			<label multiline="true"
				value="Status code: ${requestScope['javax.servlet.error.status_code']}" 					
				sclass="word-wrap" width="100%" />
			<separator />
			<label multiline="true"
				value="Message: ${requestScope['javax.servlet.error.message']}" 					
				sclass="word-wrap" width="100%" />
			<separator />													
			<label multiline="true"
				value="Exception Type: ${requestScope['javax.servlet.error.exception_type']}" 					
				sclass="word-wrap" width="100%" />
			<separator />							
			<label multiline="true"
				value="Exception: ${requestScope['javax.servlet.error.exception']}" 					
				sclass="word-wrap" width="100%" />
			<separator />		
			<label multiline="true"
				value="Request Uri: ${requestScope['javax.servlet.error.request_uri']}" 					
				sclass="word-wrap" width="100%" />
			<separator />		
			<label multiline="true"
				value="Servlet Name: ${requestScope['javax.servlet.error.servlet_name']}" 					
				sclass="word-wrap" width="100%" />
		</div>
		<separator />
		<hbox style="margin-left:auto; margin-right:auto">
			<button label="Continue" onClick="spaceOwner.detach()" />
			<button label="Reload"
				onClick="Executions.sendRedirect(null)" />					
		</hbox>
	</vbox>
</window>

</zk>

link publish delete flag offensive edit

answered 2012-02-23 03:34:19 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

Hi Neus,

It works fine for me, please try the test war below (ZK 6 CE included, click View Raw to download it)
TeatErrorPage.war

Regards,
ben

link publish delete flag offensive edit

answered 2012-02-23 08:06:16 +0800

Neus gravatar image Neus
1415 14

I have imported your war to my workspace. And it happens too!
When clicking the throw error button in test.zul the error page appears with the Expcetion but in the console appears a lot of errors. The first is the one is thrown with the button. After it 4 more exceptions are shown (all of them saying java.lang.IllegalStateException: getOutputStream() ya ha sido llamado para esta respuesta).
It is a separate project so my project doesn't have influence to it.
As I said the other exceptions appears in the console not with the error page.

link publish delete flag offensive edit

answered 2012-02-23 09:29:42 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

It may related to the environment, not happens on my local machine,
can not find any 'IllegalStateException' or 'getOutputStream()' in my console.

my environment:
Eclipse 3.6 / Tomcat 6 / jdk 1.6.0_22 / windows 64 bit

Regards,
ben

link publish delete flag offensive edit

answered 2012-03-08 12:25:36 +0800

Neus gravatar image Neus
1415 14

Hi,
It's been along but this exception is still there.
I checked the jdk, the zk version and the tomcat version (I don't use windows 64 bits) and I couldn't find any solution.
Really this doesn't happen to anyone else? Or anyone knowswhy this exception is thrown?

Thank you!

link publish delete flag offensive edit

answered 2012-03-08 20:59:58 +0800

blacksensei gravatar image blacksensei
234 2

Hello ! i' don't know whether i should post here , but this post has helped my provide quick fix for some authorizationexception throwing in GenericForwardComposer and am unable to catch it and gracefully redirect to the appropriate page.I'm wondering if in my case there is better solution then taking exception as error. what do you think?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-02-17 10:13:48 +0800

Seen: 564 times

Last updated: Mar 08 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More