docs: public PortletApplicationContext initWebApplicationContext(PortletContext portletContext) {
          if (portletContext.getAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE) != null) {
              throw new IllegalStateException(
                      "Cannot initialize context because there is already a root portlet application context present - " +
                      "check whether you have multiple PortletContextLoader* definitions in your portlet.xml!");
          }
  
          Log logger = LogFactory.getLog(PortletContextLoader.class);
          portletContext.log("Initializing Spring root PortletApplicationContext");
          if (logger.isInfoEnabled()) {
              logger.info("Root portlet PortletApplicationContext: initialization started");
          }
          long startTime = System.nanoTime();
  
          try {
              // Store context in local instance variable, to guarantee that
              // it is available on PortletContext shutdown.
              if (this.context == null) {
                  this.context = createPortletApplicationContext(portletContext);
              }
              if (this.context instanceof ConfigurablePortletApplicationContext) {
                  configureAndRefreshPortletApplicationContext((ConfigurablePortletApplicationContext)this.context, portletContext);
              }
              portletContext.setAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE, this.context);
  
              ClassLoader ccl = Thread.currentThread().getContextClassLoader();
              if (ccl == PortletContextLoader.class.getClassLoader()) {
                  currentContext = this.context;
              }
              else if (ccl != null) {
                  currentContextPerThread.put(ccl, this.context);
              }
  
              if (logger.isDebugEnabled()) {
                  logger.debug("Published root PortletApplicationContext as PortletContext attribute with name [" +
                          PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE + "]");
              }
              if (logger.isInfoEnabled()) {
                  long elapsedTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
                  logger.info("Root PortletApplicationContext: initialization completed in " + elapsedTime + " ms");
              }
  
              return this.context;
          }
          catch (RuntimeException ex) {
              logger.error("Portlet context initialization failed", ex);
              portletContext.setAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE, ex);
              throw ex;
          }
          catch (Error err) {
              logger.error("Portlet context initialization failed", err);
              portletContext.setAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE, err);
              throw err;
          }
      }