Error Rendering View - JSF + CDI + Primefaces

Asked

Viewed 644 times

0

Good evening, I have the following context: My application uses JSF2, CDI and Primefaces, my view is yielding normally, however, if I start an F5 repeatedly ends up returning me the error of Rendering View with Nullpointerexception, my view is annotated with @Viewscoped if I switch to @Request the problem ends.

com.sun.faces.application.view.Faceletviewhandlingstrategy handleRenderException GRAVE: Error Rendering View[/pages/restricted/admin/test.xhtml] java.lang.Nullpointerexception at com.sun.faces.application.view.ViewScopeContextManager.destroyBeans(Viewscopecontextmanager.java:171) at com.sun.faces.application.view.ViewScopeContextManager.clear(Viewscopecontextmanager.java:122) at com.sun.faces.application.view.ViewScopeManager.removeEldestViewMap(Viewscopemanager.java:399) at com.sun.faces.application.view.ViewScopeManager.processPostConstructViewMap(Viewscopemanager.java:298) at com.sun.faces.application.view.ViewScopeManager.processEvent(Viewscopemanager.java:244) at com.sun.faces.application.view.ViewScopeEventListener.processEvent(Viewscopeeventlistener.java:68) at javax.faces.Event.SystemEvent.processListener(Systemevent.java:108) at javax.faces.Event.ComponentSystemEvent.processListener(Componentsystemevent.java:118) at com.sun.faces.application.Applicationimpl.processListeners(Applicationimpl.java:2169) at com.sun.faces.application.Applicationimpl.invokeListenersFor(Applicationimpl.java:2142) at com.sun.faces.application.Applicationimpl.publishEvent(Applicationimpl.java:294) at javax.faces.application.ApplicationWrapper.publishEvent(Applicationwrapper.java:739) at javax.faces.application.ApplicationWrapper.publishEvent(Applicationwrapper.java:739) at javax.faces.Component.UIViewRoot.getViewMap(Uiviewroot.java:1557) at com.sun.faces.application.view.ViewScopeContextManager.createBean(Viewscopecontextmanager.java:148) at com.sun.faces.application.view.ViewScopeContext.get(Viewscopecontext.java:137) at org.jboss.Weld.context.Passivatingcontextwrapper$Abstractpassivatingcontextwrapper.get(Passivatingcontextwrapper.java:76) at org.jboss.Weld.manager.Beanmanagerimpl.getReference(Beanmanagerimpl.java:744) at org.jboss.Weld.el.Abstractweldelresolver.lookup(Abstractweldelresolver.java:107) at org.jboss.Weld.el.Abstractweldelresolver.getValue(Abstractweldelresolver.java:90) at org.jboss.Weld.environment.Servlet.util.Forwardingelresolver.getValue(Forwardingelresolver.java:49) at javax.el.Compositeelresolver.getValue(Compositeelresolver.java:62) at com.sun.faces.el.Demuxcompositeelresolver. _getValue(Demuxcompositeelresolver.java:176) at com.sun.faces.el.Demuxcompositeelresolver.getValue(Demuxcompositeelresolver.java:203) at org.apache.el.parser.Astidentifier.getValue(Astidentifier.java:94) at org.apache.el.parser.Astvalue.getValue(Astvalue.java:137) at org.apache.el.parser.Astequal.getValue(Astequal.java:37) at org.apache.el.ValueExpressionImpl.getValue(Valueexpressionimpl.java:190) at org.jboss.Weld.el.Weldvalueexpression.getValue(Weldvalueexpression.java:50) at com.sun.faces.facelets.el.TagValueExpression.getValue(Tagvalueexpression.java:109) at javax.faces.Component.ComponentStateHelper.Eval(Componentstatehelper.java:194) at javax.faces.Component.UIComponentBase.isRendered(Uicomponentbase.java:457) at org.primefaces.Component.panelgrid.Panelgridrenderer.encodeGridBody(Panelgridrenderer.java:219) at org.primefaces.Component.panelgrid.Panelgridrenderer.encodeGridLayout(Panelgridrenderer.java:90) at org.primefaces.Component.panelgrid.Panelgridrenderer.encodeEnd(Panelgridrenderer.java:40) at javax.faces.Component.UIComponentBase.encodeEnd(Uicomponentbase.java:919) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(Htmlbasicrenderer.java:312) at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(Grouprenderer.java:114) at javax.faces.Component.UIComponentBase.encodeChildren(Uicomponentbase.java:889) at org.primefaces.renderkit.CoreRenderer.renderChild(Corerenderer.java:85) at org.primefaces.renderkit.CoreRenderer.renderChildren(Corerenderer.java:72) at org.primefaces.Component.outputpanel.Outputpanelrenderer.encodeMarkup(Outputpanelrenderer.java:65) at org.primefaces.Component.outputpanel.Outputpanelrenderer.encodeEnd(Outputpanelrenderer.java:41) at javax.faces.Component.UIComponentBase.encodeEnd(Uicomponentbase.java:919) at javax.faces.Component.UIComponent.encodeAll(Uicomponent.java:1863) at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) at javax.faces.Component.UIComponentBase.encodeChildren(Uicomponentbase.java:889) at org.primefaces.renderkit.CoreRenderer.renderChild(Corerenderer.java:85) at org.primefaces.renderkit.CoreRenderer.renderChildren(Corerenderer.java:72) at org.primefaces.Component.panel.Panelrenderer.encodeContent(Panelraddressr.java:206) at org.primefaces.Component.panel.Panelrenderer.encodeMarkup(Panelrenderer.java:123) at org.primefaces.Component.panel.Panelrenderer.encodeEnd(Panelraddressr.java:58) at javax.faces.Component.UIComponentBase.encodeEnd(Uicomponentbase.java:919) at javax.faces.Component.UIComponent.encodeAll(Uicomponent.java:1863) at javax.faces.Component.UIComponent.encodeAll(Uicomponent.java:1859) at javax.faces.Component.UIComponent.encodeAll(Uicomponent.java:1859) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Faceletviewhandlingstrategy.java:456) at com.sun.faces.application.view.MultiViewHandler.renderView(Multiviewhandler.java:133) at javax.faces.application.ViewHandlerWrapper.renderView(Viewhandlerwrapper.java:337) at org.ocpsoft.rewrite.faces.Rewriteviewhandler.renderView(Rewriteviewhandler.java:196) at javax.faces.application.ViewHandlerWrapper.renderView(Viewhandlerwrapper.java:337) at com.sun.faces.lifecycle.Renderresponsephase.execute(Renderresponsephase.java:120) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.Lifecycleimpl.render(Lifecycleimpl.java:219) at javax.faces.webapp.FacesServlet.service(Facesservlet.java:647) at org.apache.Applicationfilterchain.internalDoFilter(Applicationfilterchain.java:231) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:166) at org.apache.Tomcat.websocket.server.WsFilter.doFilter(Wsfilter.java:52) at org.apache.Applicationfilterchain.internalDoFilter(Applicationfilterchain.java:193) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:166) at org.ocpsoft.rewrite.servlet.Rewritefilter.doFilter(Rewritefilter.java:226) at org.apache.Applicationfilterchain.internalDoFilter(Applicationfilterchain.java:193) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:166) at org.apache.Catalina.core.Standardwrappervalve.invoke(Standardwrappervalve.java:198) at org.apache.Catalina.core.Standardcontextvalve.invoke(Standardcontextvalve.java:96) at org.apache.Catalina.authenticator.Authenticatorbase.invoke(Authenticatorbase.java:493) at org.apache.Catalina.core.Standardhostvalve.invoke(Standardhostvalve.java:140) at org.apache.Catalina.valves.Errorreportvalve.invoke(Errorreportvalve.java:81) at org.apache.Catalina.valves.Abstractaccesslogvalve.invoke(Abstractaccesslogvalve.java:650))

@Named
@ViewScoped
public class TesteController implements Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;
private Vendedor vendedor;

@PostConstruct
public void init() {
getVendedor();
}

public Vendedor getVendedor() {
if(vendedor == null)
vendedor = new Vendedor();
return vendedor;
}

public void setVendedor(Vendedor vendedor) {
this.vendedor = vendedor;
}

}

1 answer

0

I was in the same trouble! Most likely using a CDI Viewscoped ( javax.faces.view.Viewscoped ) in my case I was and the problem arose because I did not put the CDI to manage the Beans. I decided to make the following step:

Workaround: Configure the following Beans manager in Web.xml (if you haven’t already done so):

<resource-env-ref>
    <resource-env-ref-name>BeanManager</resource-env-ref-name>
    <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>

Place the following contents in the context.xml file:

<?xml version="1.0" encoding="UTF-8"?>
      <Context>
        <Manager pathname=""/>
       <Resource name="BeanManager" auth="Container" 
          type="javax.enterprise.inject.spi.BeanManager" 
          factory="org.jboss.weld.resources.ManagerObjectFactory"/>
      </Context>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.