Results 1 to 3 of 3

Thread: XmlWebApplicationContext and classpath

  1. #1
    Join Date
    Dec 2004
    Posts
    6

    Default XmlWebApplicationContext and classpath

    Hi!

    I am using WebSphere 5.1 as an application server, and therefore (as it says in the api), I need to use a ContextLoaderServlet instead of a listener in order to load my applicationContext.

    My problem is that my applicationContext.xml is located in a shared resource (jar) which is in the classpath. Therefore, I would like to use something like ClassPathXmlApplicationContext to load the config.

    However, ClassPathXmlApplicationContext is not of type ConfigurableWebApplicationContext and therefore I get an initialization failure when trying to use it together with the ContextLoaderServlet (given as a context parameter)

    How can I load a applicationContext.xml into a web environment when the file is NOT placed in Web-Inf, but rather in a shared jar-file?

    Any help is greately appreciated! Thanks.

    /Niklas

  2. #2
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Last edited by robyn; May 19th, 2006 at 05:06 AM.
    Randy

  3. #3
    Join Date
    Dec 2004
    Posts
    6

    Default Problem solved!

    Yes, great!! I must have missed that post...

    I actually solved my problem (while waiting for answers) by extending XmlWebApplicationContext and override getDefaultConfigLocations() to manually look up my resource from the classpath using spring's ClassPathResource, and also pointing out my subclass with the "contextClass" servlet context parameter.

    But using the "classpath:" prefix as suggested by your post is far more elegant. I will switch to that solution.

    Thanks!
    /Niklas

Similar Threads

  1. Replies: 9
    Last Post: Feb 15th, 2012, 12:19 PM
  2. Accessing classpath resources from within a jar
    By general_pattonm in forum Container
    Replies: 9
    Last Post: May 15th, 2008, 05:14 PM
  3. Replies: 6
    Last Post: Dec 18th, 2007, 09:44 PM
  4. Help loading Spring config file from classpath
    By phersh in forum Container
    Replies: 1
    Last Post: Mar 2nd, 2005, 07:20 PM
  5. Replies: 6
    Last Post: Jan 19th, 2005, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •