Failed to import Spring security bean configuration file from URL location
I am implementing spring security framework in my web app. I have all the required spring security jar files in my ear.This ear also contains my web app war file.I have created another jar file which resides in ear itself and has all the code related with security (like custom providers etc) so that i can use it in another web app in furture.This security jar file is also having the spring security bean coniguration f开发者_StackOverflow中文版ile which i m importing to my web app but it gives me exceptions while deploying ear in jboss.Follwoing are the exception & my code details...
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException
parsing XML document from class path resource [META-INF/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
Below is my web app's web.xml entry
<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:META-INF/authbeans.xml" />
</beans>
This authbeans.xml resides in security.jar which is included in ear and also mentioned in my web app's MANIFEST.MF.
Please suggest me what to do I am using Spring 3.0.5 release. Following is my ear file structure:
MyEar
|-- lib\ (contains all spring security jar files)
|
|-- mySecurity.jar (contains all security related custom code also authbeans.xml)
|
|-- myWar
|-- META-INF/MANIFEST.MF (entries for spring security jars & mySecurity.jar)
|
|-- WEB-INF
|-- applicationContext.xml (authbeans.xml included)
|-- lib\ (local jar files)
I tried this with JBOSS 5.0.1 and now app is able to locate authbeans.xml but still its not able to locate the spring security jars in ear's lib directory. When I copied all spring security jars in same level as mySecurity.jar (means directly in ear not in lib folder) then it recognizes and works fine.
But I want to keep all my third party jars in ear's lib directory.Is this is a jboss specific issue ???
Replace
<import resource="classpath:META-INF/authbeans.xml" />
with
<import resource="classpath:/META-INF/authbeans.xml" />
Upgraded to JBOSS-5,Jboss 4.2 seems have problem in recognizing jars placed in ear.
精彩评论