3

I am using OmniFaces 1.10 and Apache MyFaces 2.2.6 together in a large web application. When the application is run in production, I am getting spurious exceptions of the following form in the web server (Tomcat) log:

java.lang.NullPointerException
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver$5.put(ManagedBeanResolver.java:101)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.putInScope(ManagedBeanResolver.java:367)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:340)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:296)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:147)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96)
at org.apache.myfaces.view.facelets.tag.TagAttributeImpl.getObject(TagAttributeImpl.java:431)
at org.apache.myfaces.view.facelets.tag.TagAttributeImpl.getBoolean(TagAttributeImpl.java:143)
at org.apache.myfaces.view.facelets.tag.jstl.core.ChooseWhenHandler.isTestTrue(ChooseWhenHandler.java:68)
at org.apache.myfaces.view.facelets.tag.jstl.core.ChooseHandler.apply(ChooseHandler.java:182)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:46)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:55)
at org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:373)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:50)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:46)
at org.apache.myfaces.view.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:195)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:46)
at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:46)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:46)
at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:520)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:574)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:552)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:188)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:477)
at org.omnifaces.viewhandler.RestorableViewHandler.restoreView(RestorableViewHandler.java:80)
at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
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:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

I am sure this is a problem or at least an edge case in the application (e.g. an .xhtml file which uses some bean variables incorrectly) but I cannot reproduce it in test cases and it also never happened with previous versions of MyFaces and OmniFaces.

The exception itself seems to be triggered because OmniFaces "RestorableViewHandler" tries to restore a view just to see whether it contains a tag that it should be restored automatically. When the restored view does not contain the tag, it throws away the (already) restored view. Apart from the obvious performance issue, this also triggers this NullPointerException, so I don't want this and I am therefore looking for a way to complete disable the RestorableViewHandler. I know that when I do this, I will not be able to use the tag "enableRestorableView", but this is OK.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Markus
  • 33
  • 2
  • 1
    There's nothing technically changed in `RestorableViewHandler` for almost 2 years. I'd guess a MyFaces related issue. Building an average view should take no more than 0,05~0,15ms on modern server hardware. However the story indeed changes when managed beans are involved in building the view (via taghandlers and such) and those managed beans are not used in view expired exception error page. The desire to disable it is then understandable. – BalusC Jan 16 '15 at 09:29

1 Answers1

3

It's not possible to disable it without hacking around in OmniFaces source. As per issue 92 this has been fixed by letting <o:enableRestorableView> setting an application wide attribute once it's been used somewhere, so that the RestorableViewHandler can decide whether to try to restore the view or not.

Note that I'd really prefer to dynamically register the RestorableViewHandler, however it's not possible to dynamically register a ViewHandler when the application has already handled a request before. It would only cause an IllegalStateException.

The fix is available in today's 1.11 snapshot (and 2.1 snapshot, for 2.x users).

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555