6 Replies Latest reply: Jun 4, 2013 8:16 AM by rukbat RSS

    Caused By: java.lang.NullPointerException

    Tshifhiwa
      hi whenever i run this code am geting NPE
          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;
                  
              }
        • 1. Re: Caused By: java.lang.NullPointerException
          PhHein
          Where do you get it? Post the complete stack trace.
          • 2. Re: Caused By: java.lang.NullPointerException
            Tshifhiwa
            i get the erro in this line
             if(getbranch() != null ||!getbranch().isEmpty()){
            
            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.java:300)
                 at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
                 at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
                 at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
                 at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
                 at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)
                 at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:444)
                 at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163)
                 at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:184)
                 at oracle.adfinternal.view.faces.taglib.region.IncludeTag.__include(IncludeTag.java:442)
                 at oracle.adfinternal.view.faces.taglib.region.RegionTag$1.call(RegionTag.java:153)
                 at oracle.adfinternal.view.faces.taglib.region.RegionTag$1.call(RegionTag.java:128)
                 at oracle.adf.view.rich.component.fragment.UIXRegion.processRegion(UIXRegion.java:503)
                 at oracle.adfinternal.view.faces.taglib.region.RegionTag.doStartTag(RegionTag.java:127)
                 at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:50)
                 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.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.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.java:300)
                 at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)
                 at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
                 at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
                 at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                 at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                 at oracle.adfinternal.view.faces.config.rich.RecordRequestAttributesDuringDispatch.dispatch(RecordRequestAttributesDuringDispatch.java:44)
                 at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                 at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                 at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                 at org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl$OverrideDispatch.dispatch(FacesContextFactoryImpl.java:267)
                 at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:469)
                 at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
                 at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189)
                 at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
                 at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:911)
                 at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:367)
                 at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:222)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                 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.java:300)
                 at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
                 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
                 at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
                 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
                 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
                 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
                 at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
                 at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
                 at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
                 at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
                 at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
                 at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
                 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
                 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
                 at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
                 at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
                 at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
                 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
                 at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
            • 3. Re: Caused By: java.lang.NullPointerException
              EJP
              I get the erro in this line
              if(getbranch() != null ||!getbranch().isEmpty()){
              Of course you do. It doesn't make sense. You are only calling getbranch().isEmpty() if getbranch() is null. It cannot possibly work. Probably you meant this:
              if(getbranch() != null  && !getbranch().isEmpty())
              • 4. Re: Caused By: java.lang.NullPointerException
                PhHein
                if(getbranch() == null || !getbranch().isEmpty())
                You have to check whether getbranch() returns null instead of not null.

                EDIT: that's what you get for answering telephone calls. What EJP said.

                Edited by: PhHein on 04.06.2013 14:05
                • 5. 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;
                              
                          }
                  Edited by: adf009 on 2013/06/04 3:29 PM