Evgeni Dimitrov
Evgeni Dimitrov

Reputation: 22496

Can't find applicationContext.xml from jar in classpath

I have Maven project with Spring. I have backend project as jar in the classpath(added as maven dependency). The backend project is with Spring again and has it's own applicationContext.xml. In the frontend project I have applicationContext.xml and I want to access the application context from tha backend like this:

<import resource="classpath:applicationContext.xml" />

but i got:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext.xml]
Offending resource: ServletContext resource [/WEB-INF/appContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

Also tried:

<import resource="classpath*:applicationContext.xml" />

and

<import resource="classpath:/applicationContext.xml" />

Upvotes: 0

Views: 4399

Answers (1)

Hung Tran
Hung Tran

Reputation: 1645

If I understand correctly, you want the front end to access the applicationContext.xml of the back end project. Then classpath* is the right statement, and you should make sure namespaces of both configuration files are the same.

For example, this case won't work

Front end:

http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

Back end:

http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

Upvotes: 1

Related Questions