Announcement Announcement Module
Collapse
No announcement yet.
How works the load sequence for the .xml files? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How works the load sequence for the .xml files?

    Hello,

    Suppose my web application with the conventional files:

    1) web.xml
    2) contextApplication-*.xml
    3) faces-*.xml
    4) *.hbm.xml

    I know from the point of view of a Web App, the web.xml is the
    first one to be loaded. Which is the second one? How works
    this sequence? Where can I find out the specification or references
    for that?

    I really appreciate any comments.

    Regards,

    Nato.

  • #2
    Except for web.xml there is no predefined order.
    Here is what typically happens:
    - web.xml is loaded by the servlet engine, this triggers the load of all defined servlets, filters, listeners, ...
    - the ContextLoaderListener loads the root application context XML, this might include a bean definition for a LocalSessionFactoryBean, triggering the load of all Hibernate mapping XML files
    - the DispatcherServlet loads the web application context XML
    ...

    So you have to study web.xml to determine the order in each case.

    Erwin

    Comment


    • #3
      Originally posted by klr8 View Post
      Except for web.xml there is no predefined order.
      Here is what typically happens:
      - web.xml is loaded by the servlet engine, this triggers the load of all defined servlets, filters, listeners, ...
      - the ContextLoaderListener loads the root application context XML, this might include a bean definition for a LocalSessionFactoryBean, triggering the load of all Hibernate mapping XML files
      - the DispatcherServlet loads the web application context XML
      ...

      So you have to study web.xml to determine the order in each case.

      Erwin
      I believe that the ContextLoaderListener is always loaded first before any servlets, so the order (I think) is:

      - web.xml parsed
      - ContextLoaderListener loaded (which kicks of the root appContext)
      - all filters are loaded
      - all servlets are loaded (any DispatcherServlets will kick off their specific webAppContext.xml).

      Comment


      • #4
        Thank you very much for the prompt answer Erwin.

        Regards. Nato.

        Comment


        • #5
          Wow. These are the fastest couple of answers I ever got in any forum. Thank you so much for your contributions. Nato.

          Comment


          • #6
            There is any matter on that sequence?

            Comment


            • #7
              I am sorry, but I became a bit confused. Which answer is the correct one and is there any matter on this sequence?

              Thanks in advance. Nato.

              Comment


              • #8
                I think both I and Erwin are saying the same thing actually, I just clarified a tiny point.

                The sequence does matter, but as long as you define a correctly configured ContextLoaderListener or ContextLoaderServlet (<2.4 servlet containers) you should be fine. I should state as well that this sequence is defined by the servlet spec, not Spring.....

                Are you having any particular problems with this?

                Please read http://static.springframework.org/sp...rence/mvc.html.

                Comment


                • #9
                  Colin, thanks for your reply.

                  I have to be honest with you. As I put in the first e-mail, I am using faces-*.xml, hence the architecture for my case is spring+jsf+hibernate. So, I'm not sure if the link you sent to me I can see the issues regarding the xml files as well. I guess it's the same for both web frameworks MVC Spring and JSF.

                  My apologies, I should sent this thread for the Web list, but since you already started to answer, I couldn't.

                  With this new reply I think it's clarified my doubts.

                  I'm not handling any particular problems. I only would like to understand this sequence load files. I know the reference for the web.xml is the servlet specification, but I wasn't sure about the xml files for spring, jsf and hibernate. Like you already stated, it's all depend on the order I put in the web.xml, now everything makes sense.

                  Thank you very much. Nato.
                  Last edited by DistillingSpring; Oct 12th, 2006, 06:26 AM. Reason: mistake in the list name

                  Comment

                  Working...
                  X