title: How to import spring resource from different maven project?
body: <p>I am trying to build a web application with one maven project with client and other with security. My maven dependencies are correct but i can't load a resource in security module.</p>
  
  <p>This is my web.xml (src/main/webapp/WEB-INF/web.xml):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets 
          and Filters --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Processes application requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;
              /WEB-INF/spring/appServlet/servlet-context.xml
              &lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;mime-mapping&gt;
          &lt;extension&gt;js&lt;/extension&gt;
          &lt;mime-type&gt;application/x-javascript&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;properties&lt;/extension&gt;
          &lt;mime-type&gt;application/text&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
      &lt;mime-mapping&gt;
          &lt;extension&gt;xml&lt;/extension&gt;
          &lt;mime-type&gt;application/xml&lt;/mime-type&gt;
      &lt;/mime-mapping&gt;
  
      &lt;!-- Enables Security --&gt;
      &lt;!-- &lt;listener&gt; &lt;listener-class&gt;org.springframework.security.web.session.HttpSessionEventPublisher&lt;/listener-class&gt; 
          &lt;/listener&gt; &lt;filter&gt; &lt;filter-name&gt;monitoring&lt;/filter-name&gt; &lt;filter-class&gt;net.bull.javamelody.MonitoringFilter&lt;/filter-class&gt; 
          &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;monitoring&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; 
          &lt;/filter-mapping&gt; &lt;filter&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; 
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; 
          &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; 
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; --&gt;
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>In my root-context.xml i try to import another resource from another maven module:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  &lt;!-- &lt;beans:bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; 
      &lt;beans:property name="location" value="classpath:resources.properties"&gt; &lt;/beans:property&gt; 
      &lt;/beans:bean&gt; --&gt;
  &lt;beans:import
      resource="classpath:/META-INF/spring/appServlet/servlet-security.xml" /&gt;
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>My servlet-security.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/security"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/security
  http://www.springframework.org/schema/security/spring-security-3.0.3.xsd"&gt;
   
      &lt;http auto-config="true"  use-expressions="true"&gt;
          &lt;intercept-url pattern="/login" access="permitAll" /&gt;
          &lt;intercept-url pattern="/logout" access="permitAll" /&gt;
          &lt;intercept-url pattern="/accessdenied" access="permitAll" /&gt;
          &lt;intercept-url pattern="/**" access="hasRole('ROLE_USER')" /&gt;
          &lt;form-login login-page="/login" default-target-url="/list" authentication-failure-url="/accessdenied" /&gt;
          &lt;logout logout-success-url="/logout" /&gt;
      &lt;/http&gt;
   
      &lt;authentication-manager alias="authenticationManager"&gt;
          &lt;authentication-provider&gt;
              &lt;user-service&gt;
                  &lt;user name="vitorn" password="password1" authorities="ROLE_USER" /&gt;
              &lt;/user-service&gt;
          &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>When i deploy my war in server, i get this exception. How i can import resource form another module???</p>
  
  <pre><code>INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/appServlet/servlet-security.xml]
  ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
  org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/spring/appServlet/servlet-security.xml]
  Offending resource: ServletContext resource [/WEB-INF/spring/root-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/spring/appServlet/servlet-security.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/spring/appServlet/servlet-security.xml] cannot be opened because it does not exist
      at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
  </code></pre>