无法从URL位置导入Spring安全bean配置文件

问题描述

| 我正在Web应用程序中实现Spring安全框架。 我的耳朵里有所有必需的spring安全jar文件。这个耳朵还包含我的Web应用程序war文件。我创建了另一个jar文件,该文件驻留在ear本身中,并具有与安全相关的所有代码(例如自定义提供程序等),以便我可以在将来的另一个Web应用程序中使用它。此安全性jar文件还具有spring security bean配置文件,该文件已即时导入到我的Web应用程序中,但在将耳朵部署到jboss中时给了我例外。 ...
Caused by: org.springframework.beans.factory.BeanDeFinitionStoreException: IOException
parsing XML document from class path resource [@R_502_4133@/authbeans.xml]; nested
exception is java.io.FileNotFoundException: class path resource [Meta-
INF/authbeans.xml] cannot be opened because it does not exist at   

org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.loadBeanDeFinitions  
(XmlBeanDeFinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.loadBeanDeFinitions
(XmlBeanDeFinitionReader.java:302)
at   
org.springframework.beans.factory.support.AbstractBeanDeFinitionReader.
loadBeanDeFinitions(AbstractBeanDeFinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDeFinitionReader.
loadBeanDeFinitions(AbstractBeanDeFinitionReader.java:178)
at org.springframework.beans.factory.xml.DefaultBeanDeFinitionDocumentReader.
importBeanDeFinitionResource(DefaultBeanDeFinitionDocumentReader.java:186)
... 154 more 
以下是我的Web应用程序的web.xml条目
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
   /WEB-INF/applicationContext.xml          
</param-value>
</context-param>
applicationContext.xml:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<beans xmlns=\"http://www.springframework.org/schema/beans\" 
   xmlns:sec=\"http://www.springframework.org/schema/security\" 
   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.xsd\">  

   <import resource=\"classpath:@R_502_4133@/authbeans.xml\" />
</beans>
该authbeans.xml驻留在security.jar中,该文件包含在ear中,并在我的Web应用程序的MANIFEST.MF中提到。 请建议我该使用Spring 3.0.5版本。 以下是我的耳朵文件结构:
    MyEar
    |-- lib\\ (contains all spring security jar files)
    |    
    |-- mySecurity.jar (contains all security related custom code also authbeans.xml)
    |
    |-- myWar
           |-- @R_502_4133@/MANIFEST.MF (entries for spring security jars & mySecurity.jar)
           |
           |-- WEB-INF
                   |-- applicationContext.xml (authbeans.xml included)
                   |-- lib\\ (local jar files)
我使用JBOSS 5.0.1进行了尝试,现在应用程序可以找到authbeans.xml,但仍然无法在ear \ lib目录中找到spring安全罐。 当我以与mySecurity.jar相同的级别复制所有spring安全jar时(直接在耳朵中而不是lib文件夹中),它可以识别并正常工作。 但是我想将所有第三方jar都放在ear \ lib目录中。这是jboss特有的问题吗?     

解决方法

更换
 <import resource=\"classpath:META-INF/authbeans.xml\" />
 <import resource=\"classpath:/META-INF/authbeans.xml\" />
    ,升级到JBOSS-5后,Jboss 4.2似乎无法识别放在耳朵里的罐子。