Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:34:53+00:00 2026-05-27T23:34:53+00:00

I have a simple question, why do i always get a NPE when I

  • 0

I have a simple question, why do i always get a NPE when I invoke a managed bean method that either returns a list. I am using primefaces wizard component in my view. For instance can sometone tells me the difference between these two:

Does not work:

public List<RequiredParam> getRequiredFields() {
   if(!this.sdeCommand.getActions().isEmpty() &&this.action!=null &&!this.action.equals("")){
       for(CommandAction act:this.sdeCommand.getCommandActions()){
           if(act.getActionName().equalsIgnoreCase(this.action)){
               this.requiredFields.addAll(act.getFields());
           }
       }
   }
    return this.requiredFields;
}

However this Works:

public List<RequiredParam> getRequiredFields() {

    return this.requiredFields;
}

The view:

                                <c:forEach items="${gdsiGeodataBean.requiredFields}" var="reqs">
                                    <h:outputLabel for="#{reqs.name}" value="#{reqs.name}:* " />  
                                </c:forEach>

Error message:

java.lang.NullPointerException
    com.tsystems.appbeans.GdsiGeodataBean.getRequiredFields(GdsiGeodataBean.java:103)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
    com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    org.apache.el.parser.AstValue.getValue(AstValue.java:118)
...

my view:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:34:54+00:00Added an answer on May 27, 2026 at 11:34 pm
    this.sdeCommand.getActions().isEmpty()
    

    The above will throw an NPE if getActions() returns null. Check to make sure that getActions() != null first. This may or may not be your problem but it certainly is unsafe code and it should never pass a formal code review.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a simple question but I've developed an app that has always been using
I have a simple question. Is there a way ( using reflections I suppose
I have a simple question, but I'm about 80% sure that the answer to
I have a simple question that I am posing mostly for my curiousity. What
I have this (simple) question regarding an array. I am trying to get the
A. Simple question. I have 3 instances of Repository that depends on the Configuration.
I have a simple question and wish to hear others' experiences regarding which is
I have a simple question related to one-line programming. First an example: function test(a)
I have a simple question about Java's XML API and I hope there's a
i have pretty simple simple question (i hope so). How do i change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.