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 9249113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:06:40+00:00 2026-06-18T10:06:40+00:00

My current platform is NB 7 rc 1 and I have a JSF 2

  • 0

My current platform is NB 7 rc 1 and I have a JSF 2 app with just one “managed bean”. In time, I’m using Tomcat 7.0.34.

Here is the code where the error occurs:

 @ManagedBean
    @SessionScoped
    public class CopyController implements Serializable {
      private static final long serialVersionUID = 1L;
      private String pathBancoSentencas;
      private List<Arquivo> arquivosUpload;
      private HttpSession session;
      private List<String> listaPdfs;

      public List<Arquivo> getArquivosUpload() {
        return arquivosUpload;
      }
      public void setArquivosUpload(List<Arquivo> arquivosUpload) {
        this.arquivosUpload = arquivosUpload;
      }

      public CopyController() {
        arquivosUpload = new ArrayList<Arquivo>();
      }

      @PostConstruct
      public void doInit() {
          session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);  
    pathBancoSentencas = (String)session.getAttribute("DIRETORIO_TRABALHO");
  }  

And after processing the request, the routine calls a view like this:

            <p:dataTable value="#{copyController.arquivosUpload}" var="arquivo" paginator="true" paginatorPosition="bottom" 
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">
              <f:facet name="header">
                Item processado
              </f:facet>
              <h:column>
                <h:outputText value="#{arquivo.nome}" />
              </h:column>
            </p:dataTable>

However, the view is not displayed and this error occurs:

Caused by: java.lang.NullPointerException
    at br.jus.tjmg.dspace.copy.CopyController.doInit(CopyController.java:54)
    ... 70 more

Can someone help me?
Thanks!

  • 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-06-18T10:06:42+00:00Added an answer on June 18, 2026 at 10:06 am

    From your doInit() method,

    getExternalContext().getSession(false);
    

    This returns null if the session is currently not been created yet. But yet you’re explicitly expecting a non-null session in the next line.

    You need to pass true to trigger autocreate.

    getExternalContext().getSession(true);
    

    See also the javadoc (emphasis mine):

    If the create parameter is true, create (if necessary) and return a session instance associated with the current request. If the create parameter is false return any existing session instance associated with the current request, or return null if there is no such session.


    Unrelated to the concrete problem, that whole doInit() method is unnecessary and can be replaced by a @ManagedProperty:

    @ManagedProperty("#{DIRETORIO_TRABALHO}")
    private String pathBancoSentencas;
    

    Or, if you’re absolutely positive that you need do to it in the doInit(), a nicer way is to get it from ExternalContext#getSessionMap() instead.

    pathBancoSentencas = (String) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("DIRETORIO_TRABALHO");
    

    You should try to avoid javax.servlet.* imports in your JSF backing bean.

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

Sidebar

Related Questions

Compiler: Code::Blocks(GNU GCC) Platform: Windows(x86) Update: I have solved the problem by using chdir()
MY PLATFORM: PHP & mySQL WHAT I HAVE HERE: I have 4 tables, namely,
The problem is the target platform I am using (WP 7.1) doesn't have this
I currently have Android SDK Platform-tools 14 installed. (Edit: Seems to be the current
I have a problem with Ti.Geolocation that drives me crazy. Only using IOS platform
I'm looking into using the Mono framework for taking my current C# application cross-platform
In order to do some multi-platform GUI development, I have just switched from GTK
I'm working on a Qt mobile app for the symbian platform. I have a
I have a piece of code that can read current state of serial port
Coding Platform ASP.NET 4.0 WebForms I have two pages that are relevant here Login.aspx

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.