Announcement Announcement Module
Collapse
No announcement yet.
Can WebApplicationContext load context from classpath? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can WebApplicationContext load context from classpath?

    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.

    Code:
      <context-param>
        <param-name>contextClass</param-name>
        <param-value>org.springframework.context.support.ClassPathXmlApplicationContext</param-value>
      </context-param>
    
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</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.

  • #2
    is
    Code:
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
    			classpath&#58;/path-to-your-applicationContext-in-classpath.xml
            </param-value>
        </context-param>
    does not working?

    Comment


    • #3
      thanks, I will try that.

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

      Comment

      Working...
      X