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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:15:35+00:00 2026-06-19T03:15:35+00:00

hi all i am having an issue, i have a properties file, this stores

  • 0

hi all i am having an issue, i have a properties file, this stores all the save locations, i get the data from this file by :

public void loadProp() {
        System.out.println("Loading properties");
        InputStream in = this.getClass().getClassLoader().getResourceAsStream("config.properties"); //points to a properties file, this will load up destinations instead of having to declare them here
        try {
            configProp.load(in);
            System.out.println(configProp.getProperty("destinationPDF"));
            System.out.println(configProp.getProperty("destination"));
            System.out.println(configProp.getProperty("fileList"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("called get username");
        username = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
        System.out.println(username);


    }

i then do this to assign the value to destination

public String destination = configProp.getProperty("destination");

but whenever i use destination i get a null value, however if i use configProp.getProperty(“destination”) i get the full path, what am i doing wrong here as i want the value to be point to destination as other classes depend on it

EDIT :

This class is called on by a command button (web app)

    @ViewScoped
    @ManagedBean(name = "fileUploadController")
    public class FileUploadController {

        public boolean isUploadComplete() { //to enable the next button once finished
            return uploadComplete;
        }

        public void setUploadComplete(boolean uploadComplete) {
            this.uploadComplete = uploadComplete;
        }

        public boolean isUploadComplete2() {
            //to disable the file upload button, this will stop users uploading multiple files and over writing them as only the last file uploaded will be used
            return uploadComplete;
        }

        public void setUploadComplete2(boolean uploadComplete) {
            this.uploadComplete = uploadComplete;
        }
        /*
         public void handleFileUpload(FileUploadEvent event) {
         System.out.println("called");
         FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
         FacesContext.getCurrentInstance().addMessage(null, msg);
         }
         }
         */
        //
        //Strings for fileUpload
        //oadProp() 
        //public String fileList = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/Directory Files/directoryFiles.txt"; //
        private Properties configProp = new Properties();

        @PostConstruct
        //System.out.println(destinationPDF);
        //System.out.println(destination);
    // Get the username from the login page, this is used to create a folder for each user
        public void loadProp() {
            System.out.println("Loading properties");
            InputStream in = this.getClass().getClassLoader().getResourceAsStream("config.properties"); //points to a properties file, this will load up destinations instead of having to declare them here
            try {
                configProp.load(in);
                System.out.println(configProp.getProperty("destinationPDF"));
                System.out.println(configProp.getProperty("destination"));
                System.out.println(configProp.getProperty("fileList"));
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("called get username");
            username = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
            System.out.println(username);


        }
//String destinationPDF = configProp.getProperty("destinationPDF"); Always makes a null no idea why yet
    //private String destinationPDF = configProp.getProperty("destinationPDF");
    public String destination = configProp.getProperty("destination");
    private String username;
    //public static String destination = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/uploaded/"; // main location for uploads//TORNADO ONLY //"D:/My Documents/NetBeansProjects/printing~subversion/fileupload/uploaded/"; // USE ON PREDATOR ONLY 
    public static String NewDestination;
    public static String UploadedfileName;
    public static String CompletefileName;
    //
    //Strings for file copy
    //
    //private String destinationPDF = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/"; //USE ON TORNADO//"D:/My Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/";//USE ON PREDATOR    
    private String NewdestinationPDF;
    public static String PdfLocationViewable;
    private boolean uploadComplete;
    private boolean uploadComplete2;

    //
    public void File() {

above is the first bit of code for that class

the output in the console is :

INFO: buttonToUploadText invoked
INFO: Loading properties
INFO: D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/
INFO: D:/Documents/NetBeansProjects/printing~subversion/fileupload/Uploaded/
INFO: D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/Directory Files/directoryFiles.txt
INFO: called get username
INFO: null
INFO: destination is null
  • 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-19T03:15:36+00:00Added an answer on June 19, 2026 at 3:15 am

    Your ordering is off. This is what will happen when your bean is instantiated by the container:

    1. Constructor will be called
    2. All injected fields will be resolved
    3. PostConstruct will be called.

    Currently, you are setting the destination value before your properties have been loaded up. A very simple solution to this problem is to simply set the destination value in your @PostConstruct handler.

    @PostConstruct
    public void loadProp() {
        InputStream in = this.getClass().getClassLoader()
                .getResourceAsStream("config.properties");
        try {
            configProp.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    
        destination = configProp.getProperty("destination");
    }
    

    One advantage of this method over others is that the destination property will be correctly set every time the loadProp method is called (as opposed to only once).

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

Sidebar

Related Questions

i'm having an issue PInvoking a native function from c++... i have PInvoked all
I'm having an issue here, I am trying to get all the titles from
Hi All I am currently having an issue calling a WCF service from a
Good evening, I'm having an issue with Masonry. This is all my relevant code:
Hey y'all I'm having the weirdest issue in my ember code. (1.0-pre4) This seemingly
I am having this issue I have been struggling with for sometime and now
I am having an issue with a website developed using ASP.Net/C# sometimes taking all
I am having an issue with swapping images in IE6. Works fine in all
I am new to Windows forms and having an issue handling all the user
I'm having the following issue - I want to traverse all the xml files

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.