Announcement Announcement Module
Collapse
No announcement yet.
Loading Spring root WebApplicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading Spring root WebApplicationContext

    We have a Spring app deployed on WebSphere. There is an applicationContext.xml file in the root of the EAR. We also have an applicationContext.xml file in the WEB-INF of the WAR. This applicationContext.xml "points" to the one in the EAR. It looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <import resource="classpath:applicationContext.xml"/>
    </beans>

    We are getting the following exception when the app server starts:

    Exception caught while initializing context
    org.springframework.beans.factory.BeanDefinitionSt oreException: 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

    Has anyone experienced this? I figure that it is a claspath issue, but I'm not sure how to address it.

    Thanks,
    Bijou

  • #2
    do you have this in your web.xml?

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <!-- use spaces between locations if more than one is used -->
    <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
    </context-param>


    and

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    Comment


    • #3
      I think it would be hard for Spring to see them as two different context files as their filename is the same for the context in the EAR as in the WAR.
      applicationContext-WAR.xml and applicationContext-EAR.xml would give a more clear separation of the parent and child context.

      Comment


      • #4
        We have changed the app to use just one applicationContext.xml file - and put it under WEB-INF. We also have the following in our web.xml:

        <context-param>
        <param-name>contextConfigLocation</param-name>
        <!-- use spaces between locations if more than one is used -->
        <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
        </context-param>

        and

        <listener>
        <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
        </listener>

        Still, Websphere throws the following file not found exception when the server starts:

        [7/27/07 11:39:51:982 EDT] 00000020 WebApp E Exception caught while initializing context
        org.springframework.beans.factory.BeanDefinitionSt oreException: 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

        We really don't know where to go from here, except back to Tomcat. We were hoping we could get a non trivial Spring App to run on an application server.

        Comment


        • #5
          In addition to the Servletname-servlet.xml for the Spring MVC beans, Spring looks for the application context default to the file applicationContext.xml and location at WEB-INF. If you choose to another location then you must specify it as you have in the contextConfigLocation.

          However... When I did this I got the same error. I solved it by putting classpath:applicationContext.xml instead. Try moving your applicationContext.xml under WEB-INF, that should do the trick
          Last edited by DJViking; Jul 28th, 2007, 03:39 AM.

          Comment

          Working...
          X