Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9610

Initialize ServletContext and ServletConfig property sources eagerly in FrameworkServlet

    Details

    • Last commented by a User:
      true

      Description

      ServletContext and ServletConfig properties are added too late in FrameworkServlet initializer. I wanted to use the Environment in an ApplicationContextInitializer including the property sources from web.xml (as advertised in StandardServletEnvironment), but StandardServletEnvironment isn't initialized until the refresh starts. The workaround is easy - just call

      WebApplicationContextUtils.initServletPropertySources(
          applicationContext.getEnvironment().getPropertySources(),
          servletContext, applicationContext.getServletConfig()
      );
      

      in the ApplicationContextInitializer, for example: https://github.com/cloudfoundry/uaa/blob/master/common/src/main/java/org/cloudfoundry/identity/uaa/config/YamlServletProfileInitializer.java#L58

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cbeams Chris Beams
                Reporter:
                david_syer Dave Syer
                Last updater:
                Chris Beams
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 47 weeks, 4 days ago

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.25d
                  0.25d