PDA

View Full Version : Can WebApplicationContext load context from classpath?


vivrebien
Jul 27th, 2005, 10:30 AM
Hope this is the right place for this question.

I have a jar with all my my business/data access code/ and the spring xml files. I took this approach so I can re-use the jar in several web applications (without copying spring xml files in each application).

Is there any way to use the WebApplicationContext to load spring files from the ClassPath instead of a FileSystem?

In my web.xml, I tried to setup the ContextLoadListener's context factory class to ClassPathXmlApplicationContext.


<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.context.support.ClassPathXmlAp plicationContext</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>


But I get an error :

[org.springframework.context.ApplicationContextExce ption: Custom context class [
org.springframework.context.support.ClassPathXmlAp plicationContext] is not of ty
pe ConfigurableWebApplicationContext]


Has anyone try to do load spring xml files embedded in a jar from a web application? If so, let me know how. Thanks.

lucker
Jul 27th, 2005, 10:44 AM
is

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/path-to-your-applicationContext-in-classpath.xml
</param-value>
</context-param>


does not working?

vivrebien
Jul 27th, 2005, 11:21 AM
thanks, I will try that.

Never saw this documented (at least in spring online manual).