Announcement Announcement Module
Collapse
No announcement yet.
Load ApplicationContext no Servlet Context available Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Load ApplicationContext no Servlet Context available

    What is the recommended approach of loading ApplicationContext in a class where Servlet Context isnīt available? We have a service layer and all service objects are created through a BusinessServiceFactory. Temporarily Iīm using FileSystemXmlApplicationContext, however I need a file system independent solution. I tried to use XmlWebApplicationContext, however it throws an exception(BeanFactory not initialized - call 'refresh' before accessing beans via the context). I called refresh on XmlWebApplicationContext and it throws another exception (Cannot resolve ServletContextResource without ServletContext). Could you please provide me or point me to some example, I couldnīt find it anywhere.
    Thanks,
    Luciana

  • #2
    How about ClassPathXmlApplicationContext?

    Comment


    • #3
      Itīs a J2EE application, and applicationContext.xml is located under WEB-INF dir, so it seems to me that XmlWebApplicationContext makes more sense... Iīm still looking for an example using it.
      Regards,
      Luciana

      Comment


      • #4
        I solved that way: created a Servlet which starts Business Service Factory. This Servlet is loaded on startup after ContextLoaderServlet, and it uses
        Code:
                 ApplicationContext applicationContext = 
                         WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());

        Comment

        Working...
        X