myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Neumann <stefan.neum...@freiheit.com>
Subject Exception Handling
Date Wed, 13 Dec 2006 17:09:29 GMT
Hi,

I want to catch all unhandled exceptions at one point and send error
mails to the developer. So I decided to use the the first way discribed
here: http://wiki.apache.org/myfaces/Handling_Server_Errors.

I throw intentionally a NPE but it never gets caught.

So what I have done so far:

public class ArkFacesServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	private static final Log LOG = LogFactory.getLog(ArkFacesServlet.class);
		
	private FacesServlet _delegate;
	private String _errorPage;
	
	public ArkFacesServlet() {
		LOG.info("Creating Ark Faces Servlet.");
	}
	
	/* (non-Javadoc)
	 * @see
javax.servlet.http.HttpServlet#service(javax.servlet.ServletRequest,
javax.servlet.ServletResponse)
	 */
	@Override
	public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
		try{
			LOG.debug("New Service!");
			_delegate.service(request, response);
			LOG.debug("no error occured!");
		}catch (Throwable e) {
			LOG.debug("Reveived an error!");
			e.printStackTrace();
			// do something here
		}
	}
	/* (non-Javadoc)
	 * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
	 */
	@Override
	public void init(ServletConfig servletConfig) throws ServletException {
	     _delegate = new FacesServlet();
	     _delegate.init(servletConfig);
	     _errorPage = servletConfig.getInitParameter(INIT_PARAM_ERROR_PAGE);
	}

[..]
}
--------------

web.xml:

--------------

<servlet>
	<servlet-name>Faces Servlet</servlet-name>
<servlet-class>com.freiheit.ark.control.ArkFacesServlet</servlet-class>
	<init-param>	
		<param-name>errorPage</param-name>
		<param-value>/pages/error.jsf</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>

---------------

All I get in the log is something like that:

---------------

[DEBUG] 2006-12-13 17:12:29,025 http-8080-Processor24
com.freiheit.ark.control.ArkFacesServlet.service:
New Service!

[ERROR] 2006-12-13 17:14:09,822 http-8080-Processor24
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/abba].log:
Error calling action method of component with id
searchUser:userData:0:_id164

javax.faces.FacesException: Error calling action method of component
with id searchUser:userData:0:_id164
        at
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
        at
org.apache.shale.view.faces.ViewActionListener.processAction(ViewActionListener.java:73)
        at javax.faces.component.UICommand.broadcast(UICommand.java:106)
        at javax.faces.component.UIData.broadcast(UIData.java:513)
        at
org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:274)
        at
org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:250)
        at
org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:405)
        at
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
        at
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
        at
com.freiheit.ark.control.ArkFacesServlet.service(ArkFacesServlet.java:60)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:61)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:268)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
com.freiheit.ark.auth.business.AuthUserContextFilter.doFilter(AuthUserContextFilter.java:54)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
com.freiheit.ark.control.CacheControlFilter.doFilter(CacheControlFilter.java:32)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
        at
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
        at
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
        at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
        at
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
        at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
        at
org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
        at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
        at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:191)
        at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
        at
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
        at
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:67)
        at
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:223)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: javax.faces.el.EvaluationException:
/pages/user/search/search.xhtml @216,82
action="#{userController.modifyUserForSearch}":
java.lang.NullPointerException: Catch that!
        at
com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
        at
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
        ... 59 more
Caused by: java.lang.NullPointerException: Catch that!
        at
com.freiheit.ark.user.presentation.UserController.modifyUserForSearch(UserController.java:486)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
        at
com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
        at
com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
        at
com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
        ... 60 more


[DEBUG] 2006-12-13 17:14:46,274 http-8080-Processor24
com.freiheit.ark.control.ArkFacesServlet.service:
no error occured!


What's the problem?

Thanks for your help

Stefan

-- 

Stefan Neumann
Dipl.-Ing. (FH)

freiheit.com technologies gmbh
Straßenbahnring 22 / 20251 Hamburg, Germany
fon       +49 (0)40 / 890584-0
fax       +49 (0)40 / 890584-20

1CB2 BA3C 168F 0C2B 6005 FC5E 3EBA BCE2 1BF0 21D3

Bücher kaufen und Freie Software fördern | http://bookzilla.de/

Mime
View raw message