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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:41:37+00:00 2026-06-10T08:41:37+00:00

I use Spring MVC with java config. And I have two context configuration classes:

  • 0

I use Spring MVC with java config.

And I have two context configuration classes: RootContext and ServletContext.

RootContext class is loaded via <context-param> in web.xml

Here is the code of RootContext:

@Configuration
@EnableTransactionManagement
@Import(DaoConfig.class)
@PropertySource("/WEB-INF/config/application.properties")
public class RootContext {

    @Autowired
    private Environment env;

    @Bean(destroyMethod = "close")
    public DataSource dataSource() {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
        dataSource.setUrl(env.getProperty("jdbc.url"));
        dataSource.setUsername(env.getProperty("jdbc.username"));
        dataSource.setPassword(env.getProperty("jdbc.password"));
        return dataSource;
    }

    @Bean
    public PlatformTransactionManager transactionManager() {
        return new DataSourceTransactionManager(dataSource());
    }
}

If I run the application, I got this error:

java.io.FileNotFoundException: class path resource [WEB-INF/config/application.properties] cannot be opened because it does not exist

Everything works fine if I move application.properties file to classpath. But I want it to be in /WEB-INF/config directory.

Any suggestion how to solve this error?

Should I put @PropertySource("/WEB-INF/config/application.properties") line to ServletContext instead of RootContext??

Thank you.

  • 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-10T08:41:39+00:00Added an answer on June 10, 2026 at 8:41 am

    I know this is a late reply but I hope this may be useful for anyone having the same issue.

    You can do this by setting context-param in your web.xml and access it in configuration class with @PropertyResource.

    web.xml

    <context-param>
        <param-name>myProperties</param-name>
        <param-value>${catalina.home}/conf/application.properties</param-value>
    </context-param>
    

    AppConfig.class

    @Configuration
    @PropertySource("file:${myProperties}")
    public class AppConfig{
    
        @Autowired
        Environment env;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use Spring MVC 3.0 and JSP. I have an object: public class ObjectWrapper
I am trying got use spring-mvc tag inside java-script file, here is what i
I use Spring MVC (via Spring Roo) to build a small web application for
earlier I use Spring MVC and annotation @ModelAttribute. @Controller public class ArticleController { @ModelAttribute(articles)
I have learned how to use Spring MVC 3, but I am very interested
I have a spring MVC java application and I'm serializing joda DateTime to json.
I have a java web application based on Spring MVC. The task is to
I am using Spring MVC to develop a Java webapp. I have a setup
I have a Google App Engine app using Java and Spring MVC 3.0. A
I have a Java servlet website, but does not use any frameworks like Spring

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.