myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard W. Smith, Jr." <smithh032...@gmail.com>
Subject Re: TomEE/MyFaces: EL exception NulPointerException for h:selectOneMenu
Date Tue, 18 Dec 2012 00:42:42 GMT
Leonardo,

I just confirmed the following:

1. @PostConstruct, pf_RollingStockController.init() method is called
2. the h:selectOneMenu (below) is responsible, because the server log
(below) will show that the setter has null as an argument value

<h:selectOneMenu value="#{pf_rollingStockController.filterYear}">
    <f:selectItem itemValue="0"

itemLabel="#{pf_rollingStockController.selectOneFilterYear}" />
    <f:selectItems value="#{pf_rollingStockController.allYears}"/>
    <p:ajax partialSubmit="true"
listener="#{pf_rollingStockController.prepareList()}"
            update=":pageContentPanel"/>
</h:selectOneMenu>


Please note that the test steps do not include/involve clicking the
selectOneMenu, so the filterYear = 0 was not (or should not have been) set
to NULL by PrimeFaces' p:ajax component. So, is MyFaces or TomEE/openejb
responsible for h:selectOneMenu setting the value to NULL?

server log below:


INFO: pf_UsersController.loginUser(): administrator logged in at Mon Dec 17
19:19:40 EST 2012
Dec 17, 2012 7:19:59 PM pf.ApplicationScopeBean log
INFO: pf_RollingStockController.init(): BEFORE filterYear = 0
Dec 17, 2012 7:19:59 PM pf.ApplicationScopeBean log
INFO: pf_RollingStockController.init(): AFTER filterYear = 0; filterYear
(now) = 0
Dec 17, 2012 7:20:03 PM javax.faces.component._ExternalSpecifications
isBeanValidationAvailable
INFO: MyFaces Bean Validation support enabled
Dec 17, 2012 7:20:03 PM pf.ApplicationScopeBean log
INFO: pf_RollingStockController.setFilterYear(): argument filterYear = 0;
this.filterYear = 0
Dec 17, 2012 7:20:03 PM pf.ApplicationScopeBean log
INFO: pf_RollingStockController.setFilterYear(): argument filterYear =
null; this.filterYear = 0
Dec 17, 2012 7:20:03 PM pf.ApplicationScopeBean log
INFO: pf_RollingStockController.setFilterYear(): argument filterYear =
null; this.filterYear = null
Dec 17, 2012 7:22:20 PM pf.ApplicationScopeBean log
INFO: pf_UsersController.logout(): administrator logged out at Mon Dec 17
19:22:20 EST 2012



On Mon, Dec 17, 2012 at 3:38 PM, Leonardo Uribe <lu4242@gmail.com> wrote:

> Hi
>
> In my opinion, the stack traces shows that @PostConstruct is not
> called or filterYear is set to null in some other place.
>
> If the container is not calling @PostConstruct, TomEE is the one to
> blame, but first I would check that assumption, using a debugger
> or with a System.out.println().
>
> regards,
>
> Leonardo Uribe
>
> 2012/12/17 Howard W. Smith, Jr. <smithh032772@gmail.com>:
> > Leonardo,
> >
> > Thanks for your response to my previous email where you proposed a fix
> > using MyFaces Commons (mcc taghandler).
> >
> > Now, I'm wondering if this is TomEE or MyFaces. For some reason,
> filterYear
> > (Integer) seems to be NULL when enduser/myself click the following
> > commandButton.
> >
> > <p:commandButton value="Browse" icon="ui-icon-search" immediate="true"
> >
>  actionListener="#{pf_rollingStockController.prepareList()}"
> >                  ajax="false"/>
> >
> >
> > Please note the following:
> >
> > 1. web app is composed of CDI-managed-beans, running via TomEE 1.5.1 and
> > MyFaces 2.1.10, and JUEL 2.2.5
> > 2. the xhtml and bean did not result in exception when I was running
> > Glassfish and JSF-managed-beans (at this time, last year, when this xhtml
> > and bean was in demand)
> > 3. I had to check for NULL in 'getSelectOneFilterYear()' to fix this
> issue.
> >
> > xhtml
> >
> > <h:selectOneMenu value="#{pf_rollingStockController.filterYear}">
> >     <f:selectItem itemValue="0"
> >
> > itemLabel="#{pf_rollingStockController.selectOneFilterYear}" />
> >     <f:selectItems value="#{pf_rollingStockController.allYears}"/>
> >     <p:ajax partialSubmit="true"
> > listener="#{pf_rollingStockController.prepareList()}"
> >             update=":pageContentPanel"/>
> > </h:selectOneMenu>
> >
> >
> > bean
> >
> >
> > import javax.inject.Named;
> > import javax.enterprise.context.SessionScoped;
> >
> > @Named("pf_rollingStockController")
> > @SessionScoped
> > public class pf_RollingStockController implements Serializable {
> >
> >     private Integer filterYear;
> >
> >     @PostConstruct
> >     protected void init() {
> >
> >         filterYear = 0;
> >
> >     }
> >
> >     public String getSelectOneFilterYear() {
> >         /*** HAD TO ADD THIS TO FIX THE EXCEPTION BELOW ***/
> >         if (filterYear == null) {
> >             filterYear = 0;
> >         }
> >         /*** HAD TO ADD THIS TO FIX THE EXCEPTION BELOW ***/
> >         if (filterYear == 0)
> >             return "Select One";
> >         else
> >             return "Show All";
> >     }
> >
> >
> >
> > stacktrace in TomEE's log
> >
> >
> > javax.servlet.ServletException: javax.el.ELException:
> > java.lang.NullPointerException
> > at javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> > at
> >
> org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> > at
> >
> org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:148)
> > at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> > at pf.LoginFilter.doFilter(LoginFilter.java:204)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> > at
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> > at
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> > at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
> > at
> >
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> > at
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> > at
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> > at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
> > at
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> > at
> >
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> > at
> >
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> > at
> >
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> > at
> >
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> > at
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> > at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> > at java.lang.Thread.run(Thread.java:722)
> > Caused by: org.apache.myfaces.view.facelets.el.ContextAwareELException:
> > javax.el.ELException: java.lang.NullPointerException
> > at
> >
> org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:104)
> > at
> javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:249)
> > at javax.faces.component.UISelectItem.getItemLabel(UISelectItem.java:129)
> > at
> >
> org.apache.myfaces.shared.util.SelectItemsIterator.hasNext(SelectItemsIterator.java:124)
> > at
> >
> org.apache.myfaces.shared.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:798)
> > at
> >
> org.apache.myfaces.shared.renderkit.RendererUtils.getSelectItemList(RendererUtils.java:764)
> > at
> >
> org.apache.myfaces.shared.renderkit.html.HtmlSelectableRendererBase.internalRenderSelect(HtmlSelectableRendererBase.java:74)
> > at
> >
> org.apache.myfaces.shared.renderkit.html.HtmlMenuRendererBase.renderMenu(HtmlMenuRendererBase.java:91)
> > at
> >
> org.apache.myfaces.shared.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:76)
> > at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
> > at
> javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
> > at
> >
> org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:370)
> > at
> >
> org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:194)
> > at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
> > at
> javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
> > at
> >
> org.primefaces.component.datatable.DataTableRenderer.encodeColumnHeaderContent(DataTableRenderer.java:409)
> > at
> >
> org.primefaces.component.datatable.DataTableRenderer.encodeColumnHeader(DataTableRenderer.java:373)
> > at
> >
> org.primefaces.component.datatable.DataTableRenderer.encodeThead(DataTableRenderer.java:584)
> > at
> >
> org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:213)
> > at
> >
> org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:186)
> > at
> >
> org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:79)
> > at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
> > at javax.faces.component.UIData.encodeEnd(UIData.java:1699)
> > at
> org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:62)
> > at
> >
> org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:46)
> > at
> >
> org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:202)
> > at
> >
> org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:119)
> > at
> >
> org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:56)
> > at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
> > at
> org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:62)
> > at
> >
> org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:46)
> > at
> org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:60)
> > at
> >
> org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:46)
> > at
> >
> org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:46)
> > at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
> > at
> org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:62)
> > at
> >
> org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:46)
> > at
> >
> org.primefaces.extensions.component.layout.LayoutPaneRenderer.encodeBegin(LayoutPaneRenderer.java:141)
> > at
> >
> javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:587)
> > at
> javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:517)
> > at
> javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
> > at
> javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
> > at
> javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
> > at
> >
> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1981)
> > at
> >
> org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
> > at
> >
> javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
> > at
> >
> javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
> > at
> >
> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116)
> > at
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
> > at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
> > ... 27 more
> > Caused by: javax.el.ELException: java.lang.NullPointerException
> > at javax.el.BeanELResolver.getValue(BeanELResolver.java:307)
> > at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
> > at de.odysseus.el.tree.impl.ast.AstProperty.eval(AstProperty.java:77)
> > at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:51)
> > at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:30)
> > at
> de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:122)
> > at
> >
> org.apache.webbeans.el.WrappedValueExpression.getValue(WrappedValueExpression.java:68)
> > at
> >
> org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96)
> > ... 76 more
> > Caused by: java.lang.NullPointerException
> > at
> >
> jsf.rollingStock.pf_RollingStockController.getSelectOneFilterYear(pf_RollingStockController.java:1407)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> > at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:601)
> > at
> >
> org.apache.webbeans.intercept.InterceptorHandler.invoke(InterceptorHandler.java:322)
> > at
> >
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:117)
> > at
> >
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:108)
> > at
> >
> jsf.rollingStock.pf_RollingStockController_$$_javassist_37.getSelectOneFilterYear(pf_RollingStockController_$$_javassist_37.java)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> > at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:601)
> > at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
> > ... 83 more
> >
> >
> > Please let me know your thoughts.
> >
> > Thanks,
> > Howard
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message