docs: public static PortletApplicationContext getPortletApplicationContext(
              PortletRequest request, PortletContext portletContext) throws IllegalStateException {
  
          PortletApplicationContext portletApplicationContext = (PortletApplicationContext) request.getAttribute(
                  ContribDispatcherPortlet.PORTLET_APPLICATION_CONTEXT_ATTRIBUTE);
          if (portletApplicationContext == null) {
              if (portletContext == null) {
                  throw new IllegalStateException("No PortletApplicationContext found: not in a DispatcherPortlet request?");
              }
              portletApplicationContext = PortletApplicationContextUtils2.getRequiredPortletApplicationContext(portletContext);
          }
          
          return portletApplicationContext;
      }