ICEfaces
  1. ICEfaces
  2. ICE-1023

Seam: Missing Form exception when using dynamic menus under Seam

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC
    • Assignee Priority:
      P1

      Description

      as noted in the forum: http://www.icefaces.org/JForum/posts/list/2910.page

      Dynamic menus cause the following exception under Seam. Tested with both Seam
      1.0.1 and Seam 1.1, ICEfaces 1.5 and 1.5.1pre. Non-dynamic menus work fine.

      2006-11-23 16:41:42,718 ERROR [STDERR] java.lang.NullPointerException: Missing
      Form - the UIComponent of type [class
      com.icesoft.faces.component.menubar.MenuItem] requires a containing form.
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.validateParameters(DomBasicRenderer.java:484)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.component.menubar.MenuItemRenderer.decode(MenuItemRenderer.java:77)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIComponentBase.decode(UIComponentBase.java:500)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.component.menubar.MenuItemBase.processDecodes(MenuItemBase.java:71)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.component.menubar.MenuItemBase.decodeRecursive(MenuItemBase.java:88)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.component.menubar.MenuItemBase.processDecodes(MenuItemBase.java:69)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.component.menubar.MenuBar.decodeRecursive(MenuBar.java:266)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.component.menubar.MenuBar.processDecodes(MenuBar.java:250)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIForm.processDecodes(UIForm.java:53)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:135)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.myfaces.lifecycle.LifecycleImpl.applyRequestValues(LifecycleImpl.java:214)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:69)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCycle(BlockingServlet.java:442)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(BlockingServlet.java:429)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:288)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      2006-11-23 16:41:42,718 ERROR [STDERR] at
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      2006-11-23 16:41:42,734 ERROR [STDERR] at
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      2006-11-23 16:41:42,734 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      2006-

        Activity

        Hide
        Ted Goddard added a comment -

        Is there a form in the page?

        Show
        Ted Goddard added a comment - Is there a form in the page?
        Hide
        Philip Breau added a comment -

        Created an attachment (id=116)
        test case

        Show
        Philip Breau added a comment - Created an attachment (id=116) test case
        Hide
        Ted Goddard added a comment -

        It's possible that this is the same problem that we're seeing with Effects in Seam. If the effect
        is returned by the EJB, it is loaded by the EJB classloader and is not visible to the web application
        (or is a different class by the same name because of a different classloader). Potentially this
        is caused by the MenuItem being instantiated in Bean.java

        Show
        Ted Goddard added a comment - It's possible that this is the same problem that we're seeing with Effects in Seam. If the effect is returned by the EJB, it is loaded by the EJB classloader and is not visible to the web application (or is a different class by the same name because of a different classloader). Potentially this is caused by the MenuItem being instantiated in Bean.java
        Hide
        Ken Fyten added a comment -

        Target v1.6.

        Show
        Ken Fyten added a comment - Target v1.6.
        Hide
        Ken Fyten added a comment -

        This issue needs to be analyzed along with other Seam related issues and distilled to root causes.

        Show
        Ken Fyten added a comment - This issue needs to be analyzed along with other Seam related issues and distilled to root causes.
        Hide
        Greg Dick added a comment -

        This is a problem with the menuRenderer when the menu is dynamically generated. Adnan says the menuRenderer looks upwards for the enclosing form during the render phase, and suspects the dynamically generated menu can't find its parent correctly.

        This doesn't appear to be a Seam issue directly, but requires Seam to get the example to work. I have a large testcase, if anyone is interested.

        Show
        Greg Dick added a comment - This is a problem with the menuRenderer when the menu is dynamically generated. Adnan says the menuRenderer looks upwards for the enclosing form during the render phase, and suspects the dynamically generated menu can't find its parent correctly. This doesn't appear to be a Seam issue directly, but requires Seam to get the example to work. I have a large testcase, if anyone is interested.
        Hide
        Greg Dick added a comment -

        I've tracked this down to the use of the conversation scope annotation in the backing bean which is the source of the dynamic menu. This turns out to have been a poor choice, and it's informative to know why.

        On the first render of the page, an instance of the Bean class is instantiated, and queried for the dynamic menu. The component tree is created, the menu is rendered, the Bean object is inserted into the Conversation scope, and then at the end of the request, the Conversation is terminated, since there is no code nor annotations to make this a long running conversation.

        The problem occurs when the next partial submit starts the next request lifecycle. A new Conversation is started, the UIViewRoot is discovered, A new Bean instance is created, since no instance of the Bean component is saved in the freshly created Conversation context, and a new MenuItem is created that has not been rendered before, and therefore, it hasn't been placed in the component tree, and it's parent references are null. This leads to the NullPointer exception.

        The solution to this problem is to put the Bean component in a context which will preserve it from request to request. PageContext is the ideal candidate. Session Scope would work, but the Bean will exist until the session ends, which may not be ideal, and Conversation scope would work, if the author is interested in managing conversation state to last beyond the single short lived conversation scope.

        @Scope(ScopeType.PAGE)
        @Name("bean")
        public class Bean {

        Show
        Greg Dick added a comment - I've tracked this down to the use of the conversation scope annotation in the backing bean which is the source of the dynamic menu. This turns out to have been a poor choice, and it's informative to know why. On the first render of the page, an instance of the Bean class is instantiated, and queried for the dynamic menu. The component tree is created, the menu is rendered, the Bean object is inserted into the Conversation scope, and then at the end of the request, the Conversation is terminated, since there is no code nor annotations to make this a long running conversation. The problem occurs when the next partial submit starts the next request lifecycle. A new Conversation is started, the UIViewRoot is discovered, A new Bean instance is created, since no instance of the Bean component is saved in the freshly created Conversation context, and a new MenuItem is created that has not been rendered before, and therefore, it hasn't been placed in the component tree, and it's parent references are null. This leads to the NullPointer exception. The solution to this problem is to put the Bean component in a context which will preserve it from request to request. PageContext is the ideal candidate. Session Scope would work, but the Bean will exist until the session ends, which may not be ideal, and Conversation scope would work, if the author is interested in managing conversation state to last beyond the single short lived conversation scope. @Scope(ScopeType.PAGE) @Name("bean") public class Bean {
        Hide
        Ken Fyten added a comment -

        This is an application bean scoping issue. See the above advice if you are experiencing this problem.

        Show
        Ken Fyten added a comment - This is an application bean scoping issue. See the above advice if you are experiencing this problem.

          People

          • Assignee:
            Greg Dick
            Reporter:
            Philip Breau
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: