Error java.lang.NullPointerException JSF -


this question has answer here:

i'm using jsf/primefaces, i'm getting npe, i'm invoking method "registrar" form appears i'm doing wrong. have class profesorbean.java , view edicion.xhtml

**class: profesorbean** ...............................................  @managedbean(name="profesorbean") @sessionscoped  public class profesorbean {     private profesor profesor;     private list<profesor> profesores;     private integer autogenerado=2;  public string registrar(){     if (profesor.getcodigo()!=null) {                  }else {         profesor.setcodigo(autogenerado);         profesores.add(profesor);         autogenerado++;     }     profesor=null;     return "listado"; }  } ............................................... 

here part of form submitted edicion.xhtml

............................................... <f:facet name="footer">                         <p:commandbutton value="#{msjs.form_boton_registrar}"                                           action="#{profesorbean.registrar}"                                          update="@form"                                          ajax="false"                                         />                         <p:commandbutton value="#{msjs.form_boton_limpiar}"                                           update="panel"                                           process="@this"  >                             <p:resetinput target="panel" />                         </p:commandbutton>                         <p:commandbutton  action="listado"                                          value="#{msjs.form_boton_regresar}"                                          process="@this"                                          immediate="true"                                          ajax="false"/>                     </f:facet> 

here error

fatal:   jsf1073: se ha interceptado javax.faces.facesexception durante el procesamiento de invoke_application 5 : uicomponent-clientid=, mensaje=#{profesorbean.registrar}: java.lang.nullpointerexception fatal:   #{profesorbean.registrar}: java.lang.nullpointerexception javax.faces.facesexception: #{profesorbean.registrar}: java.lang.nullpointerexception @ com.sun.faces.lifecycle.invokeapplicationphase.execute(invokeapplicationphase.java:89) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198) @ javax.faces.webapp.facesservlet.service(facesservlet.java:646) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673) @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:357) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:260) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:188) @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:191) @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:168) @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:189) @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:288) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:206) @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:136) @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:114) @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77) @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:838) @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:113) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:115) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:55) @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:135) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:564) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:544) @ java.lang.thread.run(thread.java:745)  caused by: javax.faces.facesexception: #{profesorbean.registrar}: java.lang.nullpointerexception @ com.sun.faces.application.actionlistenerimpl.processaction(actionlistenerimpl.java:118) @ javax.faces.component.uicommand.broadcast(uicommand.java:315) @ javax.faces.component.uiviewroot.broadcastevents(uiviewroot.java:790) @ javax.faces.component.uiviewroot.processapplication(uiviewroot.java:1282) @ com.sun.faces.lifecycle.invokeapplicationphase.execute(invokeapplicationphase.java:81) ... 30 more  caused by: javax.faces.el.evaluationexception: java.lang.nullpointerexception @ javax.faces.component.methodbindingmethodexpressionadapter.invoke(methodbindingmethodexpressionadapter.java:101) @ com.sun.faces.application.actionlistenerimpl.processaction(actionlistenerimpl.java:102) ... 34 more  caused by: java.lang.nullpointerexception @ pe.edu.cibertec.managed.profesorbean.registrar(profesorbean.java:56) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ com.sun.el.parser.astvalue.invoke(astvalue.java:275) @ com.sun.el.methodexpressionimpl.invoke(methodexpressionimpl.java:304) @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:105) @ javax.faces.component.methodbindingmethodexpressionadapter.invoke(methodbindingmethodexpressionadapter.java:87) ... 35 more 

the problem not initializing member variable private profesor profesor. don't know trying inside registrar. anyway before using object should initilized. getting nullpointerexception since while calling profesor.getcodigo() profesor null. please check it.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -