2 Replies Latest reply on Sep 13, 2010 1:41 AM by nathandennis

    Custom Servlet - No Active Event Context

    ryankimber

      I'm using a custom servlet (/servlet/myServlet) and have added the web:context-filter to my components.xml with url-pattern="/servlet/*". I'm passing the conversation id as both conversationId and cid as parameters to my servlet.


      Using the Component class, I'm able to get the identity object (and perhaps some other things), but if I try to access the conversation using Component.getInstance(conversation) or any conversation-scoped objects, and IllegalStateException is thrown.


      I've reduced the post and get methods to the following code:




      |SmartCpoeUser user = (SmartCpoeUser) Component.getInstance("currentUser");
                     LOG.info("Current user is: " + user.getEmailAddress());
                     Conversation conversation = (Conversation) Component.getInstance("conversation");
                     if (LOG.isInfoEnabled())
                     {
                          LOG.info("Conversation retrieved from component is " + conversation.getId());
                     }|



      During execution, Current user is ryan@blah.com gets written to the console, but the call to retrieve the conversation (or any conversation-scoped components) fails with IllegalStateException - no active event context.


      I've updated all of my Seam .jar files to 2.2.0GA, to no avail.


      Could you please provide some guidance? Thanks in advance.

        • 1. Re: Custom Servlet - No Active Event Context
          ryankimber

          It appears that, if there's an uncaught exception in the custom servlet, Seam is kicking an IllegalStateException back to the browser, rather than the actual exception.


          I've wrapped my code in a try{...}catch(Exception e) block and discovered that some required components haven't been injected into a component that I was using.


          This leads me to my next problem. Why can't I get the context-filter to recover the conversation properly? I'm passing the cid as a parameter (in fact, I'm passing it twice - once with cid as the parameter name and once with conversationId as the name).


          Still, the conversation that I get within my servlet is a ServerContext and isn't populated with any of components that are in the conversation I was expecting.

          • 2. Re: Custom Servlet - No Active Event Context
            nathandennis

            thank you.  it was driving me insane because i remember a bug from a previous version that behaved the same way though i knew it couldnt be that because i already had custom servlets running on this project. i was fairly sure this error normally happens when preceded by another error... just couldnt figure out why it wasnt included in the stack trace. 2 points extra credit.