3 Replies Latest reply: Jun 4, 2013 7:32 AM by Tshifhiwa RSS

    Caused By: java.lang.NullPointerException

    Tshifhiwa
      hi am trying to do depandant lov but am geting NPE WHEN MY PAGE LOAD,am in jdeveloper 11.1.1.6.0
      i must seletc this lov first
      <af:selectOneChoice value="#{bindings.Branch.inputValue}"
                                    required="#{bindings.Branch.hints.mandatory}"
                                    shortDesc="#{bindings.Branch.hints.tooltip}"
                                    id="soc10" simple="true" autoSubmit="true">
                  <f:selectItems value="#{bindings.Branch.items}" id="si15"/>
                </af:selectOneChoice>
      
      based on the above lov selection i must display
      <af:selectOneChoice
                                    shortDesc="#{bindings.Roleaccesscode.hints.tooltip}"
                                    id="soc7"
                                    simple="true"
                                    valueChangeListener="#{pageFlowScope.InternalUserBean.InternalType}"
                                    value="#{pageFlowScope.InternalUserBean.userType}"
                                    partialTriggers="soc10">
                  <af:forEach var="item"
                              items="#{pageFlowScope.InternalUserBean.childRoles}">
                    <af:selectItem value="#{item}" label="#{item}" id="tu7g"/>
                  </af:forEach>
                </af:selectOneChoice>
      
          public String getbranch(){
              String brachcode = null;
              DCIteratorBinding it0 = ADFUtil.findIterator("IntUsr1Iterator");
              RowSetIterator rsi = it0.getRowSetIterator();
              Row rw = rsi.first();
              
             brachcode = (String)rw.getAttribute("Branch");
              
              return brachcode;
          }
          
             public   String[]   getChildRoles() {           
                  String[] roles = null;
                 if(getbranch() != null ||!getbranch().isEmpty()){
                     int  count =0; 
                 
                 if(getbranch().equalsIgnoreCase("Deeds")){ 
                        count = this.getUserTypesDeeds().length ;            
                         roles = new String[count]  ;  
                     for( int countt = 0; countt <  this.getUserTypesDeeds().length; countt++){
                      String  t = (String) this.getUserTypesDeeds()[countt];
                      roles[countt] = t; 
                   //   cs++;
              
                     }}
                     else {
                 if (getbranch().equalsIgnoreCase("NGMS")){
                     count = this.getUserTypesSurvey().length;
                     roles = new String[count];
                  for( int counts = 0; counts <  this.getUserTypesSurvey().length; counts++){
                      
                  //    System.out.println("counts" +counts);
                      String t = (String)this.getUserTypesSurvey()[counts];
                //      y++;
                   //   System.out.println("values " + t);
                      roles[counts] = t;
                     // roles[cs] = t;
                     // System.out.println("TESTY "+ counts);
                     // cs++;
                      //roles[count] = t;
                      
                  }
                 }
                 }}
                 return roles;
                  
              }
      the error am geting is
      Caused By: java.lang.NullPointerException
           at view.InternalBean.getChildRoles(InternalBean.java:374)
           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.el.BeanELResolver.getValue(BeanELResolver.java:261)
           at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
           at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
           at com.sun.el.parser.AstValue.getValue(Unknown Source)
           at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
           at org.apache.myfaces.trinidadinternal.taglib.ForEachTag.doStartTag(ForEachTag.java:117)
           at oracle.jsp.runtime.tree.OracleJspIterationTagNode.executeHandler(OracleJspIterationTagNode.java:43)
           at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:261)
           at oracle.jsp.runtime.tree.OracleJspClassicTagNode.evalBody(OracleJspClassicTagNode.java:87)
           at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:58)
           at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:261)
           at oracle.jsp.runtime.tree.OracleJspNode.execute(OracleJspNode.java:89)
           at oracle.jsp.runtime.tree.OracleJspClassicTagNode.evalBody(OracleJspClassicTagNode.java:87)
           at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:58)
           at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:261)
           at oracle.jsp.runtime.tree.OracleJspNode.execute(OracleJspNode.java:89)
           at oracle.jsp.runtimev2.ShortCutServlet._jspService(ShortCutServlet.java:89)
           at oracle.jsp.runtime.OracleJspBase.service(OracleJspBase.java:29)
           at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:665)
           at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:385)
           at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:810)
           at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:734)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.j
      
      the error is pointing in this line if(getbranch() != null ||!getbranch().isEmpty()){
      Edited by: adf009 on 2013/06/04 2:36 PM

      Edited by: adf009 on 2013/06/04 2:37 PM

      Edited by: adf009 on 2013/06/04 2:37 PM
        • 1. Re: Caused By: java.lang.NullPointerException
          Beardman
          Hi,
          why don't you just set a breakpoint in the method getbranch and find the exact point where the NPE occurs. Then fix it :)
          Why don't you use the debugger, I could'nt live without it.
          /Beardman
          • 2. Re: Caused By: java.lang.NullPointerException
            paramu
            Hi,

            put debug and check the below lines., i think iterator become null...

            DCIteratorBinding it0 = ADFUtil.findIterator("IntUsr1Iterator");
            RowSetIterator rsi = it0.getRowSetIterator();
            Row rw = rsi.first();


            parames,
            • 3. Re: Caused By: java.lang.NullPointerException
              Tshifhiwa
                     public   String[]   getChildRoles() {           
                          String[] roles = null;
                          if(getbranch() == null ||getbranch().isEmpty()){
                          
                          }else{
                             int  count =0; 
                         
                         if(getbranch().equalsIgnoreCase("Deeds")){ 
                                count = this.getUserTypesDeeds().length ;            
                                 roles = new String[count]  ;  
                             for( int countt = 0; countt <  this.getUserTypesDeeds().length; countt++){
                              String  t = (String) this.getUserTypesDeeds()[countt];
                              roles[countt] = t; 
                           //   cs++;
                      
                             }}
                             else {
                         if (getbranch().trim().equalsIgnoreCase("NGMS")){
                             count = this.getUserTypesSurvey().length;
                             roles = new String[count];
                          for( int counts = 0; counts <  this.getUserTypesSurvey().length; counts++){
                              
                          //    System.out.println("counts" +counts);
                              String t = (String)this.getUserTypesSurvey()[counts];
                        //      y++;
                           //   System.out.println("values " + t);
                              roles[counts] = t;
                             // roles[cs] = t;
                             // System.out.println("TESTY "+ counts);
                             // cs++;
                              //roles[count] = t;
                              
                          }
                         }
                         }}
                         return roles;
                          
                      }