Weld
  1. Weld
  2. WELD-855

Error while catching NonexistentConversationException with Seam Faces/Catch

    Details

    • Type: Bug Bug
    • Status: Resolved (View Workflow)
    • Priority: Major Major
    • Resolution: Out of Date Out of Date
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Glassfish 3.1 M2 (b41), weld 1.1 patched with Stuart's WELD-846 patch.
    • Similar Issues:
      Show 10 results 

      Description

      I have a Faces app, with the exception handler:
      void conversationExpired(@Handles CaughtException<NonexistentConversationException> t)

      {...}

      When I pull up a URL with an invalid cid, I get the stacktrace below.

      (copied from SEAMCATCH-46)

      Stacktrace:
      ---------------
      java.lang.RuntimeException: Exception invoking method [conversationExpired] on object [ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler@264d6a2c], using arguments [org.jboss.seam.exception.control.CaughtException@24758259]
      at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:547)
      at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:458)
      at org.jboss.seam.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:189)
      at org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:189)
      at org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:129)
      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:597)
      at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
      at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
      at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
      at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
      at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
      at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270)
      at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
      at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222)
      at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632)
      at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:619)
      at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:613)
      at org.jboss.seam.faces.exception.CatchExceptionHandler.handle(CatchExceptionHandler.java:81)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
      at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
      at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
      at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
      at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:465)
      at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:253)
      at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1192)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.IllegalStateException: Unable to load current conversations from the associated request, something went badly wrong when associate() was called
      at org.jboss.weld.context.AbstractConversationContext.getCurrentConversation(AbstractConversationContext.java:413)
      at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:91)
      at com.sun.faces.application.view.MultiViewHandler.getRedirectURL(MultiViewHandler.java:381)
      at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204)
      at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204)
      at org.jboss.weld.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:134)
      at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:166)
      at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:77)
      at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:27)
      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:597)
      at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:535)
      ... 59 more

        Gliffy Diagrams

          Activity

          Hide
          Ales Justin added a comment -

          Ah, forget previous comment.
          I see your code being invoked here: "at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:27)"

          It looks like conversation handling gets messed up.
          How should this work if you push in an invalid cid?

          Show
          Ales Justin added a comment - Ah, forget previous comment. I see your code being invoked here: "at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:27)" It looks like conversation handling gets messed up. How should this work if you push in an invalid cid?
          Hide
          Brian Leathem added a comment -

          If I push an invalid cid, a NonexistentConversationException is thrown as expected. Seam Catch has been configured as a JSF Excpetion Hanlder, to handle exceptions. As it tries to invoke the method that handles this exception, an IllegalStateException is thrown while trying to restore the conversation.

          This IllegalStateException should not be thrown. In this case there is no Conversation to restore, which is why the NonexistentConversationException was thrown in the first place.

          Please le me know if I can add any further explanation as to the expected behaviour.

          Show
          Brian Leathem added a comment - If I push an invalid cid, a NonexistentConversationException is thrown as expected. Seam Catch has been configured as a JSF Excpetion Hanlder, to handle exceptions. As it tries to invoke the method that handles this exception, an IllegalStateException is thrown while trying to restore the conversation. This IllegalStateException should not be thrown. In this case there is no Conversation to restore, which is why the NonexistentConversationException was thrown in the first place. Please le me know if I can add any further explanation as to the expected behaviour.
          Hide
          Pete Muir added a comment -

          Brian, this looks like the age old problem of the contexts not being properly set up inside servlet forwards, which I thought we were past. It's look like you are using form auth below? Can you debug and see if the WeldListener.beginRequest is properly invoked for this "request"?

          Show
          Pete Muir added a comment - Brian, this looks like the age old problem of the contexts not being properly set up inside servlet forwards, which I thought we were past. It's look like you are using form auth below? Can you debug and see if the WeldListener.beginRequest is properly invoked for this "request"?
          Hide
          Brian Leathem added a comment -

          I can confirm that WeldListener.requestInitialized is invoked when I request a URL with an non-existent cid. I don't see a beginRequest method in Weld Listener.

          Note: I am using the latest Weld 1.1 SNAPSHOT.

          Show
          Brian Leathem added a comment - I can confirm that WeldListener.requestInitialized is invoked when I request a URL with an non-existent cid. I don't see a beginRequest method in Weld Listener. Note: I am using the latest Weld 1.1 SNAPSHOT.
          Hide
          Pete Muir added a comment -

          Sorry, got confused with method names. Can you check that it is specifically called for the form auth forward, not for the original request. Assuming you are coming from a JSF page I think you should see it hit twice.

          Show
          Pete Muir added a comment - Sorry, got confused with method names. Can you check that it is specifically called for the form auth forward, not for the original request. Assuming you are coming from a JSF page I think you should see it hit twice.
          Hide
          Brian Leathem added a comment -

          Looking at this with levels instead of breakpoints one can see the method is hit only once.

          WeldListener.requestInitialized begins with the trace message:
          log.trace(REQUEST_INITIALIZED, event.getServletRequest());

          Steps:
          1) Start the application
          2) Visit a protected URL
          3) Log in to the application
          4) Ensure the protected page renders correctly
          5) append "?cid=5", or some other bogus conversation id to the URL, and click enter.

          The following log output is produced, where one can see the WELD-000708 message only one time, before the stack trace:

          ---------------------
          FINEST: WELD-000708 Initializing request org.apache.catalina.connector.RequestFacade@111a848b
          INFO: Catch integration enabled
          WARN: Using JSF provided instance, unable to find a BeanManaged instance for class javax.faces.validator.BeanValidator
          WARNING: StandardWrapperValve[FacesServlet]: PWC1406: Servlet.service() for servlet FacesServlet threw exception
          java.lang.RuntimeException: Exception invoking method [conversationExpired] on object [ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler@352d8328], using arguments [org.jboss.seam.exception.control.CaughtException@3efdd25e,com.sun.faces.context.FacesContextImpl@9fe39a1]
          at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:547)
          at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:458)
          at org.jboss.seam.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:189)
          at org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:189)
          at org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:130)
          at org.jboss.seam.exception.control.org$jboss$weld$bean-WEB-INF$lib$seam-catch-impl-3$0$0-SNAPSHOT-ManagedBean-class_org$jboss$seam$exception$control$ExceptionHandlerDispatch_$$WeldClientProxy.executeHandlers(org$jboss$weld$bean-WEB-INF$lib$seam-catch-impl-3$0$0-SNAPSHOT-ManagedBean-class_org$jboss$seam$exception$control$ExceptionHandlerDispatch$$_WeldClientProxy.java)
          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:597)
          at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
          at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
          at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
          at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
          at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
          at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
          at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
          at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270)
          at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
          at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222)
          at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632)
          at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:619)
          at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:613)
          at org.jboss.seam.faces.exception.CatchExceptionHandler.handle(CatchExceptionHandler.java:83)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
          at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
          at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
          at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
          at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:662)
          Caused by: java.lang.IllegalStateException: Unable to load current conversations from the associated request, something went badly wrong when associate() was called
          at org.jboss.weld.context.AbstractConversationContext.getCurrentConversation(AbstractConversationContext.java:413)
          at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:91)
          at com.sun.faces.application.view.MultiViewHandler.getRedirectURL(MultiViewHandler.java:381)
          at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204)
          at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204)
          at org.jboss.weld.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:134)
          at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:166)
          at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:77)
          at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:29)
          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:597)
          at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)
          at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
          at ca.triumf.mis.qms.workrequest.jsf.exception.org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler_$$WeldClientProxy.conversationExpired(org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler$$_WeldClientProxy.java)
          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:597)
          at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:535)
          ... 52 more

          FINEST: WELD-000709 Destroying request org.apache.catalina.connector.RequestFacade@111a848b
          ---------------

          Show
          Brian Leathem added a comment - Looking at this with levels instead of breakpoints one can see the method is hit only once. WeldListener.requestInitialized begins with the trace message: log.trace(REQUEST_INITIALIZED, event.getServletRequest()); Steps: 1) Start the application 2) Visit a protected URL 3) Log in to the application 4) Ensure the protected page renders correctly 5) append "?cid=5", or some other bogus conversation id to the URL, and click enter. The following log output is produced, where one can see the WELD-000708 message only one time, before the stack trace: --------------------- FINEST: WELD-000708 Initializing request org.apache.catalina.connector.RequestFacade@111a848b INFO: Catch integration enabled WARN: Using JSF provided instance, unable to find a BeanManaged instance for class javax.faces.validator.BeanValidator WARNING: StandardWrapperValve [FacesServlet] : PWC1406: Servlet.service() for servlet FacesServlet threw exception java.lang.RuntimeException: Exception invoking method [conversationExpired] on object [ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler@352d8328] , using arguments [org.jboss.seam.exception.control.CaughtException@3efdd25e,com.sun.faces.context.FacesContextImpl@9fe39a1] at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:547) at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:458) at org.jboss.seam.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:189) at org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:189) at org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:130) at org.jboss.seam.exception.control.org$jboss$weld$bean-WEB-INF$lib$seam-catch-impl-3$0$0-SNAPSHOT-ManagedBean-class_org$jboss$seam$exception$control$ExceptionHandlerDispatch_$$ WeldClientProxy.executeHandlers(org$jboss$weld$bean-WEB-INF$lib$seam-catch-impl-3$0$0-SNAPSHOT-ManagedBean-class_org$jboss$seam$exception$control$ExceptionHandlerDispatch $$_WeldClientProxy.java) 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:597) at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59) at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222) at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632) at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:619) at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:613) at org.jboss.seam.faces.exception.CatchExceptionHandler.handle(CatchExceptionHandler.java:83) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.IllegalStateException: Unable to load current conversations from the associated request, something went badly wrong when associate() was called at org.jboss.weld.context.AbstractConversationContext.getCurrentConversation(AbstractConversationContext.java:413) at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:91) at com.sun.faces.application.view.MultiViewHandler.getRedirectURL(MultiViewHandler.java:381) at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) at org.jboss.weld.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:134) at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:166) at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:77) at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:29) 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:597) at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125) at ca.triumf.mis.qms.workrequest.jsf.exception.org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler_$$ WeldClientProxy.conversationExpired(org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler $$_WeldClientProxy.java) 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:597) at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:535) ... 52 more FINEST: WELD-000709 Destroying request org.apache.catalina.connector.RequestFacade@111a848b ---------------
          Hide
          Brian Leathem added a comment -

          I'm not sure what you mean when you ask me to "check that it is specifically called for the form auth forward, not for the original request". But I verified that the same behaviour is observed while logged out, with a page that does not require authentication.

          Show
          Brian Leathem added a comment - I'm not sure what you mean when you ask me to "check that it is specifically called for the form auth forward, not for the original request". But I verified that the same behaviour is observed while logged out, with a page that does not require authentication.
          Hide
          Pete Muir added a comment -

          Ok, that last comment is the uesful one. Can you switch out the stack traces etc. to show it without any authz in the way?

          Show
          Pete Muir added a comment - Ok, that last comment is the uesful one. Can you switch out the stack traces etc. to show it without any authz in the way?
          Hide
          Brian Leathem added a comment -

          Here's the stacktrace for an unrestricted page:

          java.lang.RuntimeException: Exception invoking method [conversationExpired] on object [ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler@238be9f2], using arguments [org.jboss.seam.exception.control.CaughtException@36ac2119,com.sun.faces.context.FacesContextImpl@5eb10c59]
          at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:547)
          at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:458)
          at org.jboss.seam.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:187)
          at org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:189)
          at org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:128)
          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:597)
          at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
          at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
          at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
          at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
          at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
          at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
          at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
          at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270)
          at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
          at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222)
          at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632)
          at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:619)
          at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:613)
          at org.jboss.seam.faces.exception.CatchExceptionHandler.handle(CatchExceptionHandler.java:68)
          ... 29 more
          Caused by: java.lang.IllegalStateException: Unable to load current conversations from the associated request, something went badly wrong when associate() was called
          at org.jboss.weld.context.AbstractConversationContext.getCurrentConversation(AbstractConversationContext.java:413)
          at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:91)
          at com.sun.faces.application.view.MultiViewHandler.getRedirectURL(MultiViewHandler.java:381)
          at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204)
          at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204)
          at org.jboss.weld.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:134)
          at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:166)
          at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:55)
          at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:29)
          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:597)
          at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)
          at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
          at ca.triumf.mis.qms.workrequest.jsf.exception.org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler_$$WeldClientProxy.conversationExpired(org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler$$_WeldClientProxy.java)
          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:597)
          at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:535)
          ... 51 more

          Show
          Brian Leathem added a comment - Here's the stacktrace for an unrestricted page: java.lang.RuntimeException: Exception invoking method [conversationExpired] on object [ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler@238be9f2] , using arguments [org.jboss.seam.exception.control.CaughtException@36ac2119,com.sun.faces.context.FacesContextImpl@5eb10c59] at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:547) at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:458) at org.jboss.seam.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:187) at org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:189) at org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:128) 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:597) at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59) at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222) at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632) at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:619) at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:613) at org.jboss.seam.faces.exception.CatchExceptionHandler.handle(CatchExceptionHandler.java:68) ... 29 more Caused by: java.lang.IllegalStateException: Unable to load current conversations from the associated request, something went badly wrong when associate() was called at org.jboss.weld.context.AbstractConversationContext.getCurrentConversation(AbstractConversationContext.java:413) at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:91) at com.sun.faces.application.view.MultiViewHandler.getRedirectURL(MultiViewHandler.java:381) at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:204) at org.jboss.weld.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:134) at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:166) at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:55) at ca.triumf.mis.qms.workrequest.jsf.exception.ExceptionCatchHandler.conversationExpired(ExceptionCatchHandler.java:29) 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:597) at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125) at ca.triumf.mis.qms.workrequest.jsf.exception.org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler_$$ WeldClientProxy.conversationExpired(org$jboss$weld$bean-WorkRequest-ManagedBean-class_ca$triumf$mis$qms$workrequest$jsf$exception$ExceptionCatchHandler $$_WeldClientProxy.java) 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:597) at org.jboss.seam.solder.reflection.Reflections.invokeMethod(Reflections.java:535) ... 51 more
          Hide
          Ryan Slominski added a comment - - edited

          I'm getting this exception and I'm not using Seam / Faces Catch. I simply have a custom exception handler to handle NonexistentConversationExceptions (i.e. the user bookmarks a page with a cid in the URL and tries to access it later).

          I'd like to simply redirect the user to the same page (which would start a new conversation). If I invoke the NavigationHandler (directly or indirectly via ViewHandler.getActionURL) I get the IllegalStateException.

          This seems like a pretty important bug since this is a common case (User tries to access a nonexistent conversation). One workaround is to perform a redirect without invoking the NavigationHandler (ExternalContext.redirect).

          Show
          Ryan Slominski added a comment - - edited I'm getting this exception and I'm not using Seam / Faces Catch. I simply have a custom exception handler to handle NonexistentConversationExceptions (i.e. the user bookmarks a page with a cid in the URL and tries to access it later). I'd like to simply redirect the user to the same page (which would start a new conversation). If I invoke the NavigationHandler (directly or indirectly via ViewHandler.getActionURL) I get the IllegalStateException. This seems like a pretty important bug since this is a common case (User tries to access a nonexistent conversation). One workaround is to perform a redirect without invoking the NavigationHandler (ExternalContext.redirect).
          Hide
          Stuart Douglas added a comment -

          I can't reproduce this on AS7, I think this may be a Glassfish issue

          Show
          Stuart Douglas added a comment - I can't reproduce this on AS7, I think this may be a Glassfish issue
          Hide
          Darren Kramer added a comment -

          I am having the same problem with Tomcat 7. I am able to catch the NonexistentConversationException. However, I then get a followup IllegalStateException. Tracing through the code, I see that what is happening is that in WeldPhaseListener inside of activateConversations() it is throwing the NonexistentConversationException. But because it is throwing it, it never calls "conversationContext.activate(cid);" which would have created a Conversation if one didn't exist. So in the later phases we still don't have a valid Conversation and that is when the IllegalStateException comes from. I was able to work around this in my ExceptionHandler by adding:

          ConversationContext conversationContext = Container.instance().deploymentManager().instance().select(Context.class).select(HttpConversationContext.class).get();

          conversationContext.activate(null);

          But that is obviously a hack that I wouldn't want to normally do.

          According to the javadoc for NonexistentConversationException, the container is supposed to throw this exception when the Conversation cannot be restored but should also create a new conversation. It doesn't appear that is happening.

          Show
          Darren Kramer added a comment - I am having the same problem with Tomcat 7. I am able to catch the NonexistentConversationException. However, I then get a followup IllegalStateException. Tracing through the code, I see that what is happening is that in WeldPhaseListener inside of activateConversations() it is throwing the NonexistentConversationException. But because it is throwing it, it never calls "conversationContext.activate(cid);" which would have created a Conversation if one didn't exist. So in the later phases we still don't have a valid Conversation and that is when the IllegalStateException comes from. I was able to work around this in my ExceptionHandler by adding: ConversationContext conversationContext = Container.instance().deploymentManager().instance().select(Context.class).select(HttpConversationContext.class).get(); conversationContext.activate(null); But that is obviously a hack that I wouldn't want to normally do. According to the javadoc for NonexistentConversationException, the container is supposed to throw this exception when the Conversation cannot be restored but should also create a new conversation. It doesn't appear that is happening.
          Hide
          Darren Kramer added a comment -

          As a followup, I switched over to use Jboss AS7 and I still experience the exact same problem. So I can reproduce it using Weld on Tomcat 7 as well as using AS7.

          Show
          Darren Kramer added a comment - As a followup, I switched over to use Jboss AS7 and I still experience the exact same problem. So I can reproduce it using Weld on Tomcat 7 as well as using AS7.
          Hide
          Ove Ranheim added a comment -

          I experience the same too and thanks for the workaround/hack in conjunction with Seam Catch it "solves" the problem, after the call to conversationContext.active(null) and event.handled().

          In my app I get the NonexistentConversationException when:

          1) SearchForm with a commandButton (excepted behavior is to have a non conversation scope when clicked)

          2) RegisterForm part of a long-running conversation

          3) If RegisterForm is not completed and the conversation ended, said user click on the search-button in SearchForm; the NonexistentConversationException is being thrown.

          With the hack described above, the cid from RegisterForm is still appended to the URL within the action to Search. But, it does work.

          Show
          Ove Ranheim added a comment - I experience the same too and thanks for the workaround/hack in conjunction with Seam Catch it "solves" the problem, after the call to conversationContext.active(null) and event.handled(). In my app I get the NonexistentConversationException when: 1) SearchForm with a commandButton (excepted behavior is to have a non conversation scope when clicked) 2) RegisterForm part of a long-running conversation 3) If RegisterForm is not completed and the conversation ended, said user click on the search-button in SearchForm; the NonexistentConversationException is being thrown. With the hack described above, the cid from RegisterForm is still appended to the URL within the action to Search. But, it does work.
          Hide
          Joshua Davis added a comment -

          I'm having a similar issue (JBoss AS 7.0.2.Final, Seam 3.1.0.Beta2), which can be easily reproduced by typing in a bad conversation id (e.g. http://blahblahblah/somepage.xhtml?cid=666). I've got a SeamCatch exception handler, which does get invoked but then no matter what I do it always throws an IllegalStateException when rendering.

          @Darren Kramer - To implement the workaround inside JBoss AS 7... what's the Container class? Can't / shouldn't I just use BeanManager?

          Show
          Joshua Davis added a comment - I'm having a similar issue (JBoss AS 7.0.2.Final, Seam 3.1.0.Beta2), which can be easily reproduced by typing in a bad conversation id (e.g. http://blahblahblah/somepage.xhtml?cid=666 ). I've got a SeamCatch exception handler, which does get invoked but then no matter what I do it always throws an IllegalStateException when rendering. @Darren Kramer - To implement the workaround inside JBoss AS 7... what's the Container class? Can't / shouldn't I just use BeanManager?
          Hide
          Darren Kramer added a comment -

          The Container class is: org.jboss.weld.Container. The fact that I am referencing the Weld CDI implementation instead of using a solution that would work for any CDI implementation (if any other implementations also experience this bug) is why I label this as a hack. I assume with BeanManager you are referring to BeanManager.getContext()? That very well may work. There very well may be other ways to solve this problem. This was just the first way I found to work around it and frankly I stopped looking after that. Just implement a normal ExceptionHandler, and whenever you detect a NonexistentConversationException add those two lines plus any other custom code you desire and that should resolve the problem until a permanent fix is released (hopefully).

          Show
          Darren Kramer added a comment - The Container class is: org.jboss.weld.Container. The fact that I am referencing the Weld CDI implementation instead of using a solution that would work for any CDI implementation (if any other implementations also experience this bug) is why I label this as a hack. I assume with BeanManager you are referring to BeanManager.getContext()? That very well may work. There very well may be other ways to solve this problem. This was just the first way I found to work around it and frankly I stopped looking after that. Just implement a normal ExceptionHandler, and whenever you detect a NonexistentConversationException add those two lines plus any other custom code you desire and that should resolve the problem until a permanent fix is released (hopefully).
          Hide
          Joshua Davis added a comment -

          Okay, I did the following using SeamCatch, which appears to work similarly:

          @HandlesExceptions
          public class ExceptionHandlers
          {
              @Inject
              private Logger log;
           
              @Inject
              private Instance<HttpConversationContext> contextInstance;
           
              public void onNonexistentConversation(@Handles CaughtException<NonexistentConversationException> evt)
              {
                  log.error("NonexistentConversationException!\n" + evt.getException().getMessage(), evt.getException());
                  evt.markHandled();
                  HttpConversationContext conversationContext = contextInstance.get();
                  conversationContext.activate(null); // Create a new transient conversation.
              }
          }
          

          Now I have to figure out how to get it to redirect somewhere...

          Show
          Joshua Davis added a comment - Okay, I did the following using SeamCatch, which appears to work similarly: @HandlesExceptions public class ExceptionHandlers { @Inject private Logger log;   @Inject private Instance<HttpConversationContext> contextInstance;   public void onNonexistentConversation(@Handles CaughtException<NonexistentConversationException> evt) { log.error("NonexistentConversationException!\n" + evt.getException().getMessage(), evt.getException()); evt.markHandled(); HttpConversationContext conversationContext = contextInstance.get(); conversationContext.activate(null); // Create a new transient conversation. } } Now I have to figure out how to get it to redirect somewhere...
          Hide
          Ove Ranheim added a comment - - edited

          How about:

              public void conversationEndedExceptionHandler(@Handles CaughtException<NonexistentConversationException> event, Logger log)
              {
                  log.infof("Conversation ended: %s", event.getException().getMessage());
                  ConversationContext conversationContext = Container.instance().deploymentManager().instance().select(Context.class).select(HttpConversationContext.class).get();
                  conversationContext.activate(null);
                  event.handled();
              }
          

          If you need to redirect the user, do something like (requires FacesContext to be injected on your bean):

              private void handleErrorRediredct(FacesContext facesContext) {
                    facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, "/error.jsf");
              }
          

          The evt.markHandled() will cause other exception "catchers" with a lower precedence to be called. Try to use only evt.handled() unless it violates your use case and concern.

          If you stick to simply: evt.handled() your faces-config.xml will still apply and your app should work normally.

          I really hope that the Weld team could look into this and fix it once and for all. In fact, it makes the Weld + Solder (soon DeltaSpike) unusable to web developers. IMHO, it's a blocker bug for apps doing more than "Hello World!".

          The above "fix" does the work though.

          Show
          Ove Ranheim added a comment - - edited How about: public void conversationEndedExceptionHandler(@Handles CaughtException<NonexistentConversationException> event, Logger log) { log.infof("Conversation ended: %s", event.getException().getMessage()); ConversationContext conversationContext = Container.instance().deploymentManager().instance().select(Context.class).select(HttpConversationContext.class).get(); conversationContext.activate(null); event.handled(); } If you need to redirect the user, do something like (requires FacesContext to be injected on your bean): private void handleErrorRediredct(FacesContext facesContext) { facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, "/error.jsf"); } The evt.markHandled() will cause other exception "catchers" with a lower precedence to be called. Try to use only evt.handled() unless it violates your use case and concern. If you stick to simply: evt.handled() your faces-config.xml will still apply and your app should work normally. I really hope that the Weld team could look into this and fix it once and for all. In fact, it makes the Weld + Solder (soon DeltaSpike) unusable to web developers. IMHO, it's a blocker bug for apps doing more than "Hello World!". The above "fix" does the work though.
          Hide
          Joshua Davis added a comment -
          Show
          Joshua Davis added a comment - Thanks Ove. I've documented my workaround here: http://shrubbery.mynetgear.net/c/display/W/Handling+NonexistentConversationException+Gracefully
          Hide
          Ales Justin added a comment -

          @Ove: I guess your "fix" requires Catch to be used?
          But could you - as you know the details of this issue - provide a Weld patch (or actually a github pull-request)?

          Show
          Ales Justin added a comment - @Ove: I guess your "fix" requires Catch to be used? But could you - as you know the details of this issue - provide a Weld patch (or actually a github pull-request)?
          Hide
          Ove Ranheim added a comment -

          Ales, yes this requires Catch (and later on DeltaSpike) for the above handler. I suggest you bring it up with Shane or Pete, and see if Solder can be of help for handling this issue. I don't know the interior details to solve this without Catch.

          Show
          Ove Ranheim added a comment - Ales, yes this requires Catch (and later on DeltaSpike) for the above handler. I suggest you bring it up with Shane or Pete, and see if Solder can be of help for handling this issue. I don't know the interior details to solve this without Catch.
          Hide
          Pete Muir added a comment -

          Ales, we just need to fix the underlying issue, the Catch thing is just showing up this bug. I think there is just some bug in the conversation handling logic. Maybe Jason or Brian can help you create a test without catch in the picture?

          Show
          Pete Muir added a comment - Ales, we just need to fix the underlying issue, the Catch thing is just showing up this bug. I think there is just some bug in the conversation handling logic. Maybe Jason or Brian can help you create a test without catch in the picture?

            People

            • Assignee:
              Unassigned
              Reporter:
              Brian Leathem
            • Votes:
              7 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development