Bug 50789 - custom error pages and CDI/weld problem
Summary: custom error pages and CDI/weld problem
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.8
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 52423 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-02-15 12:09 UTC by Gilles Harloux
Modified: 2014-02-17 13:51 UTC (History)
1 user (show)



Attachments
test case (4.50 KB, application/x-zip-compressed)
2011-02-15 12:09 UTC, Gilles Harloux
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gilles Harloux 2011-02-15 12:09:28 UTC
Created attachment 26662 [details]
test case

I can't seem to use CDI/weld in custom error pages.

A testcase is attached. Build with "mvn install", deploy. "index.html" links to "404.jsf". If you visit this url, the page is displayed correctly. If you go somewhere else, thereby provoking a 404, it should display the same. Instead, I see tomcat's generic 404 page and this stacktrace:

Feb 15, 2011 6:04:43 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: Must call associate() before calling activate()
        at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:273)
        at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:110)
        at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:84)
        at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:224)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:95)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:465)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
        at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:466)
        at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:387)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:181)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1684)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Feb 15, 2011 6:04:43 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[errorCode=404, location=/404.jsf]
javax.servlet.ServletException: Must call associate() before calling activate()
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:465)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
        at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:466)
        at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:387)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:181)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1684)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: Must call associate() before calling activate()
        at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:273)
        at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:110)
        at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:84)
        at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:224)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:95)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
        ... 19 more

tomcat 7.0.8, java 1.6.0_23, windows XP SP3.

This issue reminds me of https://issues.apache.org/bugzilla/show_bug.cgi?id=49991, that was on the issue of using CDI/weld in the login/login failed pages used when doing form authentication.
Comment 1 Mark Thomas 2011-02-17 05:32:54 UTC
I have added a new option to the Context that enabled ServletRequestListeners to be fired on Forwards. This is in 7.0.x and will be included in 7.0.9 onwards.
Comment 2 Gilles Harloux 2011-02-18 08:32:00 UTC
Tested, it works now. Thanks!
Comment 3 Konstantin Kolinko 2012-01-05 01:00:50 UTC
*** Bug 52423 has been marked as a duplicate of this bug. ***
Comment 4 Konstantin Kolinko 2012-01-05 01:18:05 UTC
Re: bug 52423
	
If you want to backport this to Tomcat 6, then I would suggest you to prepare a patch, attach it here and reopen the issue. There is no need to create a new bug report for the same problem.

From the archives the commit that implemented this enhancement in Tomcat 7 was
http://svn.apache.org/viewvc?view=revision&revision=1071565