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

  • Home
  • SEARCH
  • 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 6614451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:20:26+00:00 2026-05-25T20:20:26+00:00

my applicationContext.xml,webmvc-config.xml are in WEB-INF/spring/applicationContext.xml when i try the following, it doesn’t load, and

  • 0

my applicationContext.xml,webmvc-config.xml are in WEB-INF/spring/applicationContext.xml

when i try the following, it doesn’t load, and i get java.io.FileNotFoundException

@ContextConfiguration(locations = { "classpath:WEB-INF/spring/applicationContext.xml" })

i am using spring 3, junit 4.7.

it works with the dirty workaround by copying applicationContext.xml in resources folder, so it’s duplicated.

and i changed the loading to:

@ContextConfiguration(locations = { "classpath:/applicationContext.xml" })

my web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

  <!-- start up and shut down Spring's root WebApplicationContext (Interface to provide configuration for a web application) -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!-- Central dispatcher for HTTP request handlers/controllers: take an incoming URI and find the right combination of handlers (generally methods on Controller classes) 
  and views (generally JSPs) that combine to form the page or resource that's supposed to be found at that location. -->
  <servlet>
    <servlet-name>p</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
            /WEB-INF/spring/webmvc-config.xml                       
            </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>p</servlet-name>
    <url-pattern>/p/*</url-pattern>
  </servlet-mapping>

  <!-- allows one to specify a character encoding for requests. 
  This is useful because current browsers typically do not set a character encoding even if specified in the HTML page or form -->
  <filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      /WEB-INF/spring/applicationContext.xml
    </param-value>
  </context-param>

  <!--  
  <filter>
  <filter-name>springSecurityFilterChain</filter-name> 
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
  </filter>

 <filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name> 
  <url-pattern>/*</url-pattern> 
  </filter-mapping>  
  -->


  <!-- Based on the popular and very useful mod_rewrite for apache, UrlRewriteFilter is a Java Web Filter for any J2EE
       compliant web application server (such as Resin or Tomcat), which allows you to rewrite URLs before they get to your
       code. It is a very powerful tool just like Apache's mod_rewrite. -->
  <filter>
  <filter-name>UrlRewriteFilter</filter-name> 
  <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  </filter>

  <filter-mapping>
  <filter-name>UrlRewriteFilter</filter-name> 
  <url-pattern>/*</url-pattern> 
  </filter-mapping>


</web-app>

please advise a better solution.

  • 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-25T20:20:27+00:00Added an answer on May 25, 2026 at 8:20 pm

    well, finally i was able to do it as follows (based on spring roo generated application):

    i put my applicationContex.xml file inside the directory:

    src/main/resources/META-INF/spring
    

    and in the web.xml:

    <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
    </context-param>
    

    and in the unit test class:

    @ContextConfiguration(locations = { "classpath:/META-INF/spring/applicationContext.xml" })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have working web-application with applicationContext.xml in WEB-INF/config/applicationContext.xml. Now i need to implement some
Eclipse is showing the following errors in my Spring's applicationContext.xml : cvc-complex-type.2.4.c: The matching
I have a web application that's based on Spring and the application contexts, applicationContext.xml
I use: <context:property-placeholder location=file:${PROJECT_CONFIG_PATH}/project.conf /> in my applicationContext.xml to get local config (one for
How do I get Spring to load Hibernate's properties from hibernate.cfg.xml ? We're using
I have the following configuration in my applicationContext.xml: <bean class=org.springframework.beans.factory.config.PropertyPlaceholderConfigurer> <property name=locations> <list> <value>classpath:app.properties</value>
I have a SpringMVC+Hibernate web application with the following files: applicationContext.xml <bean id=dataSource destroy-method=close
I have the following in my web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext-*.xml</param-value> </context-param> I have 2
I already put the log4jConfigLocation in web.xml, but I still get the following warning:
From XmlWebApplicationContext javadoc: By default, the configuration will be taken from /WEB-INF/applicationContext.xml for the

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.