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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:57:41+00:00 2026-05-15T14:57:41+00:00

Properties file location is WEB-INF/classes/auth.properties . I cannot use JSF-specific ways (with ExternalContext) because

  • 0

Properties file location is WEB-INF/classes/auth.properties.

I cannot use JSF-specific ways (with ExternalContext) because I need properties file in a service module which doesn’t have a dependency on a web-module.

I’ve already tried

MyService.class.getClassLoader().getResourceAsStream("/WEB-INF/classes/auth.properties");

but it returns null.

I’ve also tried to read it with FileInputStream but it requires the full path what is unacceptable.

Any ideas?

  • 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-15T14:57:41+00:00Added an answer on May 15, 2026 at 2:57 pm

    Several notes:

    1. You should prefer the ClassLoader as returned by Thread#getContextClassLoader().

      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      

      This returns the parentmost classloader which has access to all resources. The Class#getClassLoader() will only return the (child) classloader of the class in question which may not per se have access to the desired resource. It will always work in environments with a single classloader, but not always in environments with a complex hierarchy of classloaders like webapps.

    2. The /WEB-INF folder is not in the root of the classpath. The /WEB-INF/classes folder is. So you need to load the properties files relative to that.

      classLoader.getResourceAsStream("/auth.properties");
      

      If you opt for using the Thread#getContextClassLoader(), remove the leading /.

    The JSF-specific ExternalContext#getResourceAsStream() which uses ServletContext#getResourceAsStream() “under the hoods” only returns resources from the webcontent (there where the /WEB-INF folder is sitting), not from the classpath.

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

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't believe it has to do with known-plaintext attacks,… May 16, 2026 at 11:44 am
  • Editorial Team
    Editorial Team added an answer Just check if there's already an implementation defined. I'm pretty… May 16, 2026 at 11:44 am
  • Editorial Team
    Editorial Team added an answer Date format depends upon Database you use. For reference Date… May 16, 2026 at 11:44 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'd like to read a properties file in my applications WEB-INF folder or my
I have a Java web app that offloads some environment specific settings (Hibernate configurations,
In my properties file I have one property, which contains a comma separated list
I am trying to add some filtering to the application context file, which resides
I'm having trouble finding/getting any logging output from a web service. I have a
Using Spring 3.0 EL can we auto wire a property from a property file
I build a REST web service (using JAX-RS, Spring, Spring JMS, and ActiveMQ). I'm
I have a large application spread across multiple Spring bean definition xml files. In
I have a Spring MVC Controller class that needs a property set from a
I'm trying to configure a class with Annotation based configuration in Spring 3, which

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.