0

I have created a spring MVC application. I'm working on spring security concepts. So I've created a context configuration file name webbsite-security.xml and I've given the same file location in the context configuration path. The application fails due to an exception stating that FILENOTFOUNDEXCEPTION(applicationContext.xml not found). Is it necessary that a file named applicationContext.xml should exits even though we use some other configuration files.

1
  • show us your config, Are passing file name in web.xml? Commented Jul 17, 2012 at 9:14

1 Answer 1

1

Why would you want to call it anything else, it would go against the default standard spring way fo doing things. Just import the relevant config files into the default app context xml.

But if you want change it you must specifiy in your web.xml the following :

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

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Sign up to request clarification or add additional context in comments.

6 Comments

I don't believe the filename of app context has ever been something we should follow that strictly. In my previous projects, I have never follow this default name, and everything is fine.
@AdrianShum you are right, but it still seems a weird thing to do to me.
Not that weird in fact. There are many case you want to use another file name to align to guideline of company, or to name it in a way that better describe what it does
@AdrianShum it instantiates a new application Context, what filename could better describe that ? I am sure some companies do, doesn't make them right.
for example, in case of application context splitted into several file, calling it applicationContext-bootstrap.xml may be a better description of its use. Also, if your application can be started up using different means (as standalone app, or as a web app), it is reasonable to have different bootstrap app context xml. Giving different names to them is nothing to be surprised of. And, from my experience using Spring from 1.x era, Spring has never push applicationContext.xml as a convention that developers are suggested to follow. I don't get why you are so against using different name :P
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.