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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:15:02+00:00 2026-05-24T18:15:02+00:00

i use apache common configuration library to extract my configuration list when my web

  • 0

i use apache common configuration library to extract my configuration list when my web started.

but its always thrown error Cannot locate configuration source.

where should i put my configuration file ?

here is web.xml :

<servlet>
    <servlet-name>Quartz</servlet-name>
    <servlet-class>me.myclass.Init</servlet-class>
    <load-on-startup>1</load-on-startup>        
</servlet>

and at my code :

public void init()
{
    XMLConfiguration xmlConfig;
    try {
        xmlConfig = new XMLConfiguration("/WEB-INF/scheduler.xml");
        System.out.println(xmlConfig.getString("master"));
    } catch (org.apache.commons.configuration.ConfigurationException ex) {
        System.out.println(ex);
    } 
}
  • 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-24T18:15:03+00:00Added an answer on May 24, 2026 at 6:15 pm

    Since you are in a servlet, I recommend using the servlet context. So long as your file is in WEB-INF it should be located with this code:

      ServletContext context = getServletContext();
      File schedulerFile = new File(context.getResource("/WEB-INF/scheduler.xml").getPath());
      xmlConfig = new XMLConfiguration(schedulerFile);
    

    From the JavaDocs:
    getResource: Returns a URL to the resource that is mapped to a specified path. The path must begin with a “/” and is interpreted as relative to the current context root.

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

Sidebar

Related Questions

Decided to use Apache's Common Configuration package to parse an XML File. I decided
I use apache/passenger on my development machine, but need to add SSL support (something
I'm using Apache Common library for HTTP operations: HttpClient client = getClient(); PutMethod put
I have some Java projects that use Apache Commons Configuration and they get deployed
I have some Java projects that use Apache Commons Configuration and they get deployed
I'm trying to use Apache Commons Configuration and using ant for my build tool.
Apache and Node.js have something in common. The more I use Node.js, the more
I want to use the apache commons configuration jars in my Maven project. When
I am trying to figure out how to use Apache Commons IO DirectoryWalker .
I am trying to use GLSMultipleLinearRegression (from apache commons-math package) for multiple linear regression.

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.