<p>I'm using Spring's dependency injection but I'm running into difficulty loading a resource in my Spring config file. </p>

<p>The resource is an XML file and is in a JAR file on my classpath. I try to access it as follows:</p>

<pre><code>&lt;import resource="classpath:com/config/resources.xml" /&gt;
</code></pre>

<p>however I keep getting encountering the following error:</p>

<blockquote>
  <p>Failed to import bean definitions from URL location [classpath:com/config/resources.xml]</p>
</blockquote>

<p>The JAR file is on the classpath of a Java project, which is in turn used by my web app. Should I really be doing my Spring configuration in the web project as opposed the Java project, or does that matter?</p>

If it needs to be in the classpath of your webapp, then you should stick the JAR containing the config file into your WEB-INF/lib directory.
If you're using a webapp, then the common convention is use a ContextLoaderListener to ensure a WebApplicationContext is inserted into a standard place in the ServletContext:
```
```
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/com/config/resources.xml</param-value>
</context-param>
```
```
Then use
WebApplicationContextUtils
to fish the application context out of the servlet context using:
```
```
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
```
```