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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:00:48+00:00 2026-06-07T11:00:48+00:00

I am using SpringSource suit 2.9.2 and a newbie in Spring MVC world. I

  • 0

I am using SpringSource suit 2.9.2 and a newbie in Spring MVC world. I am trying to get an hold over object of Application Context using the following code: –

ApplicationContext context = new ClassPathXmlApplicationContext("root-context.xml");
UsersDaoImpl usersDao = context.getBean("usersDaoImpl", UsersDaoImpl.class);
Users user = usersDao.getUsers(name);
return user;

And its returning me FileNotFoundException exception. I tried different paths as well for ex. spring/root-context.xml etc. but nothing seems to work. Here is a stack trace: –

java.io.FileNotFoundException: class path resource [root-context.xml] cannot be opened because it does not exist
    org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
    org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
    org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    com.varundroid.demos.HomeController.testingDatabase(HomeController.java:65)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

enter image description here

Any help would be really appreciated.

Thanks.

  • 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-07T11:00:50+00:00Added an answer on June 7, 2026 at 11:00 am

    The main question here is why do you need to create new application context in web application instead of using the existing ones.

    As far as I can see from your setup, you should have ContextLoaderListener and DispatcherServlet declared in your web.xml. If so, you need to access context loaded by these classes rather than to create a new one.

    If you want to access ApplicationContext inside a Spring bean, you can use ApplicationContextAware or autowiring. If you want to do it outside of Spring bean (for example, in Servlet or Filter), you can use WebApplicationContextUtils.

    UPDATE:

    You don’t need to access ApplicationContext in this case. If you want to inject one Spring bean (DAO) into another one (controller), you can use autowiring:

    @Autowired
    private UserDao userDao;
    

    Also note that if UserDaoImpl is a class that implements UserDao interface it would be better to use interface when declaring dependency.

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

Sidebar

Related Questions

I’m trying to develop a Spring 3 MVC application using the Springsource Tool Suite/Eclipse
I have Roo-generated Spring MVC application connected to PostgreSQL using Hibernate. I am trying
To learn spring MVC im using this tutorial - http://static.springsource.org/docs/Spring-MVC-step-by-step/index.html It refers to spring2.5
I am using Tiles 2, Spring 3 MVC, Tomcat ver.7 and Eclipse (Springsource Tool
I'm using this tutorial: http://blog.springsource.org/2011/01/04/green-beans-getting-started-with-spring-mvc/ to run a Spring MVC app using spring's tool
I'm developing a spring MVC application. Spring version 3.1. The IDE i'm using is
I am using SpringSource Tool Suite 2.9.2 and Grails 2.0.3. I am trying to
We are using Springsource tool suite for the application development. But whenever we make
I am using Spring MVC 3.0 I have a guestbook.jsp page where I want
My spring web application is using ajax with spring, and it based in general

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.