2 Replies Latest reply on Jul 14, 2009 3:54 PM by Ronald van Kuijk

    Natural conversation and ContextualHTttpServletRequest not working

    Ronald van Kuijk Apprentice

      I run into the 'no active conversation context' error like mentioned in https://jira.jboss.org/jira/browse/JBSEAM-3689 but within a different context (pun intended :-)) namely using @Filter and a ContextualHttpServletRequest AND using natural conversations. With normal conversations it worked. What I basically did was:


      @Startup
      @Scope(ScopeType.APPLICATION)
      @Name("chibaXFormFilter")
      @BypassInterceptors
      @Filter(within = "org.jboss.seam.web.ajax4jsfFilter")
      @SuppressWarnings( { "JavadocReference" })
      public class ChibaXFormFilter extends AbstractFilter {
      
      ...
       public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
             final FilterChain filterChain) throws IOException, ServletException {
              ...
           if (requestURL.indexOf("xform") > -1) {
             new ContextualHttpServletRequest((HttpServletRequest) servletRequest) {
                @Override
                public void process() throws Exception {
                  processRequest((HttpServletRequest) servletRequest, (HttpServletResponse) servletResponse, filterChain);
                }
             }.run();
           }
           else {
              filterChain.doFilter(servletRequest, servletResponse);
           }
      }
      



      In the processRequest method I instantiate an additional seam component that does the actual work and where I can inject all kinds of components. Works great, but I want to switch to using natural confversations for these specific urls, but injection from the conversation stopped working. While debugging with making sure the filterChain.doFilter() afterwards always went off, I got the 'no conversation context active'. Switching on the trace level is saw there is  basic web request first which does not seem to recognize natural conversations. After this basic web request there is a JSF request (within the same callstack) which occurs if you go into the filterChain. That call does retrieve the natural conversation. Now if I put the filterChain.doFilter(...) before the ContextualHttpServletRequest, this jsf call comes first and in the basic web request the natural conversation is still there, so everything but one thing works again.


      What does not work anymore is that I cannot do anything with the response since the url that is called is kind of virtual and a 404 has occured. What I want to do is retrieve xhtml pages (xforms, not jsf/facelets) from the database, manipulate them (with an xslt) and send the result back to the client. This all for embedding Chiba, an xforms engine into Seam (which already worked without natural conversations)


      Is this a 'bug'? Intended behaviour and should I try to figure out some other solution?