1 2 Previous Next 18 Replies Latest reply on Feb 28, 2011 4:56 AM by Christian Yttesen

    3.3.3.CR1 and JSF 2 , NullPointerException

    Serhiy Zastavnyy Novice

      Hello All,

      I tried to run my app using jsf 2.02 and RF 3.3.3 and have NullPointerException.

      Here it is, may be someone knows what may be wrong:

      Caused by: java.lang.NullPointerException
          at org.ajax4jsf.component.EventValueExpression.quickFindComponent(EventValueExpression.java:57)
          at org.ajax4jsf.component.EventValueExpression.getComponent(EventValueExpression.java:82)
          at org.ajax4jsf.component.AbstractEventValueExpression.getValue(AbstractEventValueExpression.java:98)
          at org.richfaces.component.html.HtmlCalendar.getOnchanged(HtmlCalendar.java:1541)
          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 javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2146)
          at org.richfaces.renderkit.html.CalendarRenderer.doEncodeEnd(CalendarRenderer.java:467)
          at org.richfaces.renderkit.html.CalendarRenderer.doEncodeEnd(CalendarRenderer.java:516)
          at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
          at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
          at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:281)
          at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
          at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:279)
          at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
          at org.richfaces.renderkit.html.PanelBarItemRenderer.doEncodeChildren(PanelBarItemRenderer.java:167)
          at org.richfaces.renderkit.html.PanelBarItemRenderer.doEncodeChildren(PanelBarItemRenderer.java:162)
          at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
          at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
          at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
          at org.richfaces.renderkit.html.PanelBarRenderer.doEncodeChildren(PanelBarRenderer.java:148)
          at org.richfaces.renderkit.html.PanelBarRenderer.doEncodeChildren(PanelBarRenderer.java:143)
          at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
          at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
          at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
          at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:78)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
          at org.richfaces.renderkit.html.LayoutRenderer.renderLayout(LayoutRenderer.java:65)
          at org.richfaces.renderkit.html.LayoutRenderer.doEncodeChildren(LayoutRenderer.java:45)
          at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
          at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
          at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
          at org.richfaces.renderkit.html.PageRenderer.doEncodeChildren(PageRenderer.java:265)
          at org.richfaces.renderkit.html.PageRenderer.doEncodeChildren(PageRenderer.java:254)
          at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
          at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
          at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
          at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
          at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
          at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
          ... 27 more
      
      
        • 1. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
          Nick Belaevski Master

          Hi Serhiy,

           

          I think the reason is the same as for: http://community.jboss.org/thread/148254?tstart=0, please check that you are using richfaces-impl.jar with JSF 1.2 and richfaces-impl-jsf2.jar with JSF 2.0.

          1 of 1 people found this helpful
          • 2. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
            Serhiy Zastavnyy Novice

            Nick,

            In case using jsf 1.2 ypu was right, I used wrong impl.jar. Thank you.

             

            However, in case using jsf 2.0.2 I still have exception. I just copied 2 jsf jars and 3 rich jars from richfaces-demo-jsf2-3.3.3.CR1-tomcat6.war.

            • 3. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
              Nick Belaevski Master

              Serhiy,

               

              Can you please post page code & web.xml used?

              • 4. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                Serhiy Zastavnyy Novice

                Nick,

                I have a lot of programmatically generated code. As the error is near

                at org.richfaces.component.html.HtmlCalendar.getOnchanged(HtmlCalendar.java:1541)

                here is how I create this object

                 

                        HtmlCalendar x = new HtmlCalendar();
                
                        x.setEnableManualInput(true);
                        x.setValueExpression("value", FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
                                  createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{mybean.dateValue}", Date.class));
                        
                        x.setRequired(false);
                        
                        x.setPopup(false);
                
                            x.setStyle( "width:100%" );
                             
                        x.setTimeZone( TimeZone.getDefault() );
                        x.setLocale( FacesContext.getCurrentInstance().getViewRoot().getLocale() );
                
                     HtmlAjaxSupport x2 = new HtmlAjaxSupport();
                
                     x2.setEvent( "onchanged" );
                         x2.setReRender( "SOME_TABLE_ID" );
                         x2.addActionListener( new OrganizerValueChangeListener() );          
                          
                        x.getFacets().put("onchanged", x2 );
                

                 

                And here is my web.xml

                 

                    <context-param>
                        <param-name>com.sun.faces.verifyObjects</param-name>
                        <param-value>false</param-value>
                    </context-param>
                    <context-param>
                        <param-name>com.sun.faces.validateXml</param-name>
                        <param-value>false</param-value>
                    </context-param>
                    <context-param>
                        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                        <param-value>.xhtml</param-value>
                    </context-param>
                    <context-param>
                        <param-name>facelets.DEVELOPMENT</param-name>
                        <param-value>false</param-value>
                    </context-param>
                    <context-param>
                        <param-name>facelets.SKIP_COMMENTS</param-name>
                        <param-value>true</param-value>
                    </context-param>
                    <context-param>
                        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                    </context-param>
                    <context-param>
                        <param-name>org.richfaces.SKIN</param-name>
                        <param-value>classic</param-value>
                    </context-param>
                    <context-param>
                        <param-name>org.ajax4jsf.SKIN</param-name>
                        <param-value>classic</param-value>
                    </context-param>
                     <context-param>
                         <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                        <param-value>NEKO</param-value>
                    </context-param>
                    <context-param>
                        <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
                        <param-value>.*\..*</param-value>
                    </context-param>
                     <context-param>
                          <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
                          <param-value>true</param-value>
                     </context-param>
                     <context-param>
                          <param-name>org.richfaces.LoadScriptStrategy</param-name>
                          <param-value>ALL</param-value>
                     </context-param>
                     <context-param>
                          <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
                          <param-value>true</param-value>
                     </context-param>   
                       <context-param>
                          <param-name>org.richfaces.LoadStyleStrategy</param-name>
                          <param-value>ALL</param-value>
                     </context-param>     
                     <context-param>
                          <param-name>org.ajax4jsf.DEFAULT_EXPIRE</param-name>
                          <param-value>86401</param-value>
                     </context-param>
                    <context-param>
                        <param-name>org.richfaces.CONTROL_SKINNING</param-name>
                        <param-value>enable</param-value>
                    </context-param>
                    <context-param>
                        <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
                        <param-value>enable</param-value>
                    </context-param>
                
                    <filter>
                        <filter-name>ajax4jsf</filter-name>
                        <display-name>Ajax4jsf Filter</display-name>
                        <filter-class>org.ajax4jsf.Filter</filter-class>
                        <init-param>
                               <param-name>forceparser</param-name>
                               <param-value>false</param-value>
                          </init-param>
                    </filter>
                
                    <filter-mapping>
                        <filter-name>ajax4jsf</filter-name>
                        <servlet-name>Faces Servlet</servlet-name>
                        <dispatcher>REQUEST</dispatcher>
                        <dispatcher>FORWARD</dispatcher>
                        <dispatcher>INCLUDE</dispatcher>
                        <dispatcher>ERROR</dispatcher>
                    </filter-mapping>
                
                    <filter>
                        <filter-name>HibernateFilter</filter-name>
                        <filter-class>com.coral.HibernateSessionRequestFilter</filter-class>
                    </filter>
                
                    <filter-mapping>
                        <filter-name>HibernateFilter</filter-name>
                        <url-pattern>/*</url-pattern>
                    </filter-mapping>
                    
                    <servlet>
                        <servlet-name>Faces Servlet</servlet-name>
                        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                        <load-on-startup>1</load-on-startup>
                    </servlet>
                
                    <servlet-mapping>
                        <servlet-name>Faces Servlet</servlet-name>
                        <url-pattern>*.jsf</url-pattern>
                    </servlet-mapping>
                
                     <session-config>
                          <session-timeout>15</session-timeout>
                     </session-config>
                
                     <login-config>
                          <auth-method>BASIC</auth-method>>
                     </login-config>
                
                
                • 5. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                  Nick Belaevski Master
                  Please assign "id" to HtmlAjaxSupport explicitly, this should solve the problem.
                  • 6. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                    Serhiy Zastavnyy Novice

                    Nick,

                    Thank you, it works now for me.

                     

                    However, I found out another problem using jsf 2.

                     

                    Here is code example

                    HtmlMenuItem x = new HtmlMenuItem();
                    
                    HtmlActionParameter x2 = new HtmlActionParameter();
                    x2.setId(id);
                    x2.setValue(property);
                    x2.setAssignToBinding(FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
                                      createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{mybean.assignTo}", String.class));
                    
                    x.addActionListener(x2);
                    x.getChildren().add(x2);
                    

                     

                    It works perfect for jsf 1.2, but not for jsf 2.

                    Value "property" is not assigned to bean.

                     

                    What is the correct way to use  HtmlActionParameter and pass some value to bean   using jsf 2 ?

                    Please clarify ?


                    • 7. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                      Serhiy Zastavnyy Novice

                      Hello All,

                      Could someone please help me how to pass value to bean programmatically ?

                      My code works fine for jsf 1.2, but do not for jsf 2.

                       

                      Nick,

                      Are there any features in using HtmlActionParameter with jsf 2 together? Was HtmlActionParameter or HtmlMenuItem changed in some way for 3.3.3 release ?

                      • 8. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                        Nick Belaevski Master

                        Serhiy,

                         

                        The following code should be added:

                         

                                x2.setName("id");
                        
                        1 of 1 people found this helpful
                        • 9. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                          Serhiy Zastavnyy Novice

                          Strange behavior, but it works

                           

                          Nick,

                          Will this behaviour be present in 3.3.3 GA and RF 4 ?

                          • 10. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                            Nick Belaevski Master

                            Hi Serhiy,

                             

                            I've investigated this more and created https://jira.jboss.org/jira/browse/RF-8435 for this issue. You can look there for information on its current status. And let me thank you for reporting the problem!

                            • 11. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                              Serhiy Zastavnyy Novice

                              Nick,

                              One more thing that works using jsf 1.2 and do not after migrate to jsf 2.0.

                               

                              I use DropDownMenu and want to open ModalPanel by clicking on some menu item.

                              Using jsf 1.2 modapPanel opened, but using jsf 2.0 I had exception on GUI

                              "HTTP Status 404 - /myApp/view/.jsf".

                               

                              Here is my code:

                                      HtmlMenuItem x = new HtmlMenuItem();
                              
                                      x.setId(id);
                                       
                                      x.setSubmitMode( "ajax" );
                                      x.setValue(name);
                                      x.setActionExpression(FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
                                                createMethodExpression(FacesContext.getCurrentInstance().getELContext(), "#{bean.executeMyAction}", String.class, new Class[] {}));
                                      x.setReRender(reRender);
                                       
                                      x.setIcon(icon);
                                       
                                      x.setOncomplete( "javascript:Richfaces.showModalPanel('" + mpId +  "',{left:'" + x + "', top:'" + y + "'})" );
                                      
                                   x.setAjaxSingle(true);
                                   x.setLimitToList(true);
                                   x.setStatus(status);
                                      
                                   HtmlActionParameter x2 = new HtmlActionParameter();
                                   x2.setName("id");
                                   x2.setId(id);
                                   x2.setValue(property);
                                   x2.setAssignToBinding(FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
                                                              createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{mybean.assignTo}", String.class));
                                        
                                        
                                      x.addActionListener(x2);
                                      x.getChildren().add(x2);
                              

                               

                              Please clarify, what is wrong in my code ?

                              • 13. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                                Serhiy Zastavnyy Novice

                                Ilya,

                                There is no error in server log.

                                • 14. Re: 3.3.3.CR1 and JSF 2 , NullPointerException
                                  Nick Belaevski Master
                                  Looks like implicit navigation is causing this. Check what action method returns.
                                  1 2 Previous Next