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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:25:28+00:00 2026-06-13T23:25:28+00:00

I have two properties files, but something is wrong, inputStream is always null? <application>

  • 0

I have two properties files, but something is wrong, inputStream is always null?

<application>
    <resource-bundle>
        <base-name>resources/Bundle</base-name>
        <var>bundle</var>
    </resource-bundle>
    <locale-config>
        <default-locale>fi</default-locale>
        <supported-locale>fi</supported-locale>

    </locale-config>

    <resource-bundle>
        <base-name>resources/avainsanat</base-name>
        <var>avainsanat</var>
    </resource-bundle>
</application>

 public static List getAvainsanat() throws IOException {
    InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("avainsanat.properties");

    Properties properties = new Properties();
    List<String> values = new ArrayList<>();
    System.out.println("InputStream is: " + input);

    for (String key : properties.stringPropertyNames()) {
        String value = properties.getProperty(key);
        values.add(value);

    }
    return values;
}

Is it even possible to have two or more properties files in faces-config? If not, how can I read from my bundle only those properties which key has a prefix key_?

Thanks
Sami

  • 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-13T23:25:29+00:00Added an answer on June 13, 2026 at 11:25 pm

    You forgot to include the resources package in the path. The context class loader searches always relative to the classpath root.

    InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("resources/avainsanat.properties");
    

    The more correct way is in this particular case however using ResourceBundle#getBundle(), which is also exactly what JSF is using under the covers for <resource-bundle>:

    ResourceBundle bundle = ResourceBundle.getBundle("resources.avainsanat", FacesContext.getCurrentInstance().getViewRoot().getLocale());
    // ...
    

    (note that you should actually have used a <base-name>resources.avainsanat</base-name>)

    Alternatively, if the bean is request scoped, you could also just inject #{avainsanat} as managed property:

    @ManagedProperty("#{avainsanat}")
    private ResourceBundle bundle;
    

    Or to programmatically evaluate it:

    FacesContext context = FacesContext.getCurrentInstance();
    ResourceBundle bundle = context.getApplication().evaluateExpressionGet(context, "#{avainsanat}", ResourceBundle.class);
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the problem: I have to serialize class to XML file. But two properties
I have two string properties setup in my cocoa application's app delegate which are
I have a list of objects that have two int properties. The list is
I have a uiviewcontroller with two properties: trackName and playerObject. PlayerObject also has a
I have a Silverlight custom control with two properties; Text and Id. I have
I have some logic that depends upon two properties being set, as it executes
I have a 'Contact' class with two properties : firstName and lastName. When I
I have two objects List<Report> List<Newsletter> I need certain properties like Id Date Status
I relised I have lots of models view models with those two properties public
I have an object, Test , that has two properties, double x and double

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.